Why are the axes not aligned correctly when using PLOTYY on a subplot in MATLAB 7.0.1 (R14SP1)?
2 views (last 30 days)
Show older comments
I use the PLOTYY function to create one of the subplots in my figure window by executing the following in the MATLAB Prompt:
t = linspace(-10,10,128).'*1e-12;
I = t;
I1 = t.^2;
w = t;
S1 = t;
p = t.^2;
figure('DefaultAxesFontSize',12,'Position',[0 400 1000 650])
subplot(2,2,[1 2])
line
subplot(223)
[hax,hp(1),hp(2)] = plotyy(w*1e6,S1,w*1e6,p);
set(hax,'XLim',[1.062 1.072])
set(hax(2),'Position',get(hax(1),'Position'))
set(hax(1),'XMinorTick','on','YMinorTick','on')
However, the subplot resulting from the PLOTYY function has two axes that do not align correctly.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The ability to align axes correctly when using PLOTYY on a subplot is not available in MATLAB 7.0.1 (R14SP1).
To work around this issue, execute DRAWNOW to flush the buffer between the two SET commands that modify the size of the two axes as follows::
set(hax,'XLim',[1.062 1.072])
drawnow
set(hax(2),'Position',get(hax(1),'Position'))
0 Comments
More Answers (0)
See Also
Categories
Find more on Two y-axis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!