how to plotyy axis equal

2 views (last 30 days)
Hideki Kawakatsu
Hideki Kawakatsu on 3 Feb 2018
Answered: vijaya lakshmi on 8 Feb 2018
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

Answers (1)

vijaya lakshmi
vijaya lakshmi on 8 Feb 2018
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

Categories

Find more on Two y-axis 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!