So, ich habe nun die Skripts im Link getestet. Ich verwende fh = isolate_axes(ah, vis) in Verbindung mit fh = copyfig(fh). Leider erhalte ich nicht das gewünschte Ergebnis. Siehe angehängte Grafik...
Der Bereich ist nur rechts ausgefüllt. Ich würde aber gerne die Grafik über den gesamten Bereich gestreckt sehen.
Hm, die logische Konsequenz ist dann wohl, die Größe über die Position-Eigenschaft anzupassen. Das würde ich natürlich gerne automatisch relativ zum Axes-Handle geschehen lassen. Wie gehe ich da geschickt vor?
Zuletzt bearbeitet von MaFam am 05.08.2012, 14:15, insgesamt einmal bearbeitet
Anpassung der isolate_axes(ah, vis) brachte Erfolg. Die entsprechenden Stellen sind gekennzeichnet. Schön ist was anderes, aber es funktioniert immerhin...
Code:
%ISOLATE_AXES Isolate the specified axes in a figure on their own
%
% Examples: % fh = isolate_axes(ah) % fh = isolate_axes(ah, vis)
%
% This function will create a new figure containing the axes specified, and % also their associated legends and colorbars. The axes specified must all % be in the same figure, but they will generally only be a subset of the % axes in the figure.
%
% IN: % ah - An array of axes handles, which must come from the same figure. % vis - A boolean indicating whether the new figure should be visible. % Default: false.
%
% OUT: % fh - The handle of the created figure.
% Copyright (C) Oliver Woodford 2011-2012
% Thank you to Rosella Blatt for reporting a bug to do with axes in GUIs % 16/3/2012 Moved copyfig to its own function. Thanks to Bob Fratantonio % for pointing out that the function is also used in export_fig.m.
function fh = isolate_axes(ah, vis) % Make sure we have an array of handles if ~all(ishandle(ah)) error('ah must be an array of handles');
end % Check that the handles are all for axes, and are all in the same figure
fh = ancestor(ah(1), 'figure');
nAx = numel(ah);
for a = 1:nAx
if ~strcmp(get(ah(a), 'Type'), 'axes') error('All handles must be axes handles.');
end if ~isequal(ancestor(ah(a), 'figure'), fh) error('Axes must all come from the same figure.');
end end % Tag the axes so we can find them in the copy
old_tag = get(ah, 'Tag');
if nAx == 1
old_tag = {old_tag};
end set(ah, 'Tag', 'ObjectToCopy');
% Create a new figure exactly the same as the old one
fh = copyfig(fh); %copyobj(fh, 0);
ifnargin < 2 || ~vis
set(fh, 'Visible', 'off');
end % Reset the axes tags for a = 1:nAx
set(ah(a), 'Tag', old_tag{a});
end % Find the objects to save
ah = findall(fh, 'Tag', 'ObjectToCopy');
ifnumel(ah) ~= nAx
close(fh);
error('Incorrect number of axes found.');
end % Set the axes tags to what they should be for a = 1:nAx
set(ah(a), 'Tag', old_tag{a});
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.