As seen in an included screenshot, the EPS output of matlab is cutting of the label on the right hand side Y axis.
I am using the plotyy function, and printing to eps with: print(f1,'-depsc2' ,'figure1.eps');
I have tried changing the paperposition property, as well as the papersize property, and these seem to keep scaling with the other at each adjustment, and therefore i can never get the paper size to increase on the the right.
I have set paperpositionmode to manual.
Does anyone have any ideas?
I have created some sample code that is self sufficient and replicates the problem. The problem is created when increasing the tick and font sizes. However this is essential for my situation.
close all;
% example data:
x = 0:0.01:4;
y1 = 5*sin(2*pi*x+0.1) + 20;
y2 = 0.09*sin(2*pi*x);
tickfontsize = 18;
labelfontsize = 20;
% begin figure:
f1 = figure(1);
[ax, h1, h2 ] = plotyy(x,y1,x,y2)
% axis labels and font size:
set(get(ax(2),'Ylabel'),'String','Test1') ;
set(get(ax(1),'Ylabel'),'String','test2') ;
set(get(ax(1),'Ylabel'),'FontSize',labelfontsize) ;
set(get(ax(2),'Ylabel'),'FontSize',labelfontsize) ;
% left hand side ticks:
set(ax(1),'YLim',[6 10]);
set(ax(1),'YTick',[6:1:10]);
set(ax(1),'FontSize',tickfontsize);
% right hand side ticks:
set(ax(2),'YLim',[-0.13 0.14]);
set(ax(2),'YTick',[-0.1:0.05:0.1]);
set(ax(2),'FontSize',tickfontsize);
%print figure to eps:
print(f1,'-depsc2', './simpleoutput.eps');
plotyy(X1,Y1,X2,Y2,'function1','function2') uses function1(X1,Y1) to plot the data for the left axis and function2(X2,Y2) to plot the data for the right axis. plotyy(AX1,___) plots the data using the axes specified by AX1 for the first set of data, instead of using the current axes.
Plot Data Using Two y-AxesPlot a set of data against the left y-axis. Then, use yyaxis right to activate the right side so that subsequent graphics functions target it. Plot a second set of data against the right y-axis and set the limits for the right y-axis.
Change axes position to make them narrower:
set(ax(1),'Position', [0.13 0.11 0.775-.08 0.815]);
set(ax(2),'Position', [0.13 0.11 0.775-.08 0.815]);
% Original position was [0.13 0.11 0.775 0.815]
% Applied change in width: "-.08". Choose as desired
If you need to keep axes ratio, you should also modify height (fourth number).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With