How can I arrange the ylabels using subplot and plotyy such that they do not overlap?

Hi all:
When I combine the plotyy and subplot command the ylabels overlap:
figure
for i = 1:2
subplot(1,2,i);
ax = plotyy(1:10,randn(10,2),1:10,randn(10,2));
set(get(ax(1),'Ylabel'),'String','label1')
set(get(ax(2),'Ylabel'),'String','label2')
end
Does anybody have an idea how to resolve this issue?
Best, Peter

 Accepted Answer

You may want to move your current subplot to the right
pos = get(gca, 'Position');
pos(1) = pos(1) + 0.05;
set(gca, 'Position', pos)

3 Comments

Thanks, Thorsten. That's what I was looking for.
Moving the current subplot to the right, however, lets the label on the second yaxis disappear. How can I enlarge the drawing area of the current figure (or, conversely, shrink all the subplots by a scalar)?
For each subplot
pos = get(gca, 'Position');
pos(3:4) = 0.8*pos(3:4);
set(gca, 'Position', pos)

Sign in to comment.

More Answers (1)

Products

Asked:

on 20 Feb 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!