how to plotyy axis equal
显示 更早的评论
hello, is there an equivalent code for AXIS EQUAL for plotyy ? My concern is that when I use grid on, the dashed lines are not superposed on left side axis and right side axis. So it seems I need to rebuild the tick labels to have the same spacing unit on left and right side axis ticks. Any suggestions ? yours
回答(1 个)
vijaya lakshmi
2018-2-8
Hi Hideki,
I understand that you want to superimpose the dashed lines on both the Y-axes when using grid on.
The grid lines superimposes if the number of levels/divisions on both the Y-axes are same.
Try the following code snippet where the grid lines are superimposed
x = linspace(0,10);
y = sin(3*x);
z = sin(3*x).*exp(0.5*x);
[haxes,hline1,hline2] = plotyy(x,y,x,z);
set(haxes(2),'Xgrid','on')
set(haxes(2),'Ygrid','on')
set(haxes(1),'ylim',[-1 1])
set(haxes(2),'ylim',[-130 130])
set(haxes(2),'ytick',[-130:10:130])
% you can then for instance add a grid to the first axes as well
set(haxes(1),'ytick',linspace(-1,1,27))
set(haxes(1),'Xgrid','on')
set(haxes(1),'Ygrid','on')
If the number of levels are different, try adjusting the spacing between the levels
类别
在 帮助中心 和 File Exchange 中查找有关 Two y-axis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!