Change size of plotyy figure before saving.
Show older comments
Hi, I would like to change the size of a "plotyy" plot and save it as a eps file. Having the following figure:
h = figure(1)
[ax,p1,p2] = plotyy(aElem,z1,aElem,z2,'plot');
set(p1,'LineStyle','*','Color','k');
set(p2,'LineStyle','o','Color','k');
set(ax,{'yColor'},{'k';'k'})
set(ax,'xColor','k')
grid on
xl = xlabel(ax(2),'Crack length [mm]');
I would like to reduce the figure size before saving. The challenge for me is to do it without cutting off some of the x label text. I usually do the following for normal plots with "plot":
figWidth = 10.0; %cm
figHeight = 7.2; %cm
pixelsCm = 1680/47.5; % pixels per cm on my computer
set(gca, 'Units', 'centimeters'); % axes definitions are in cm
lpos = get(gca, 'OuterPosition'); % Gets outer position of the axes
set(gca, 'OuterPosition', [lpos(1)-0.2 lpos(2)-0.2 figWidth-1 figHeight]); % Reduce margins. [left bottom width height] are normalized to [0, 1]. Use negative values for left and bottom to trim off left/bottom margins.
set(gcf, 'PaperPositionMode', 'manual'); % Lets you setup figure size manually so that 'PaperPosition' defines size of exported grapics.
set(gcf, 'Units', 'pixels', 'Position',[10*pixelsCm 10*pixelsCm figWidth*pixelsCm figHeight*pixelsCm]); % position on screen and size of figure. The pixelsCm lets you print out in the true size on screen.
set(gcf, 'Units', 'centimeters','PaperPosition', [1 1 figWidth figHeight]); % Sets the size of the figure for the saved eps file.
and then save the figure with:
saveas(h,'figurename.eps', 'psc2')
But this only changes one of the axes. Does anyone know how to change both the same?
Thanks in advance.
Regards Brian
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!