Existing Subplot Figure Adjustment
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Imran Joseph
am 31 Aug. 2019
Bearbeitet: Adam Danz
am 1 Sep. 2019
I'm in the process of creating roughly 100 figures,
After creation they look like the figure NT_0D as it is easier for me to include the contour values.
However, for saving the figures as Images, I want to be able to adjust the figure such that looks like N1_0D.
As it looks much better, but I dont know how to write the code to adjust existing figure plots that such that I can do so without individually adjusting each figure by hand.
Any help would be greatly appreaciated.
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 31 Aug. 2019
Bearbeitet: Adam Danz
am 1 Sep. 2019
Create new axes to match a template
You could treat N1_0D.fig as a template by opening the figure, clearing all of the axes and filling them with new data.
% Name template figure (the ideal figure)
templateFig = 'N1_0D.fig';
% Open the template figure
templateHand = open(templateFig);
% Get all axis handles
axHand = findall(templateHand, 'Type', 'axes');
% Clear all axes
arrayfun(@cla,axHand)
% plot your new data; the axes order will always be the same
% "right" titled plot
contourf(axHand(1), . . .)
% "front" titled plot
contourf(axHand(2), . . .)
% "left" titled plot
contourf(axHand(3), . . .)
% "back" titled plot
contourf(axHand(4), . . .)
Alter existing axes to match a template
% Name template figure (the ideal figure)
templateFig = 'N1_0D.fig';
% Open the template figure
templateHand = open(templateFig);
% Get all axis handles
axHand = findall(templateHand, 'Type', 'axes');
% Get all colorbar handles
cbHand = findall(templateHand, 'Type', 'ColorBar');
% get axis positions
axPos = get(axHand,'Position');
% Get colorbar positions
cbPos = get(cbHand,'Position');
% Open the target figure
targetFig = 'NT_0D.fig';
targetHand = open(targetFig);
% Set the figure to match the template figure size (optional)
targetHand.Position = templateHand.Position;
% Get all axis handles
targAxHand = findall(targetHand, 'Type', 'axes');
% Get all colorpar handles
targcbHand = findall(targetHand, 'Type', 'ColorBar');
% Assuming the axes are in the same order*,
set(targAxHand, {'Position'}, axPos)
% Assuming the colorbars are in the same order*,
set(targcbHand, {'Position'}, cbPos)
% * If the axes are not in the same order you'll need to use the
% axis titles to match the correct axes. To get a list of axis
% titles: arrayfun(@(h)h.Title.String,axHand,'UniformOutput',false)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!