![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357400/image.jpeg)
scaling and change the ylim for subplot
16 次查看(过去 30 天)
显示 更早的评论
I plotted a figure with two y-axis with different y limit
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357367/image.jpeg)
But I would like to limit the yyaxis of the right axis so that right axis starts with the lower limit of the left plot and upper limit of the right plot?
Or if it is possible that the zero-axis of both plots matches?
I manually shifted the right plotted axis so that the zeros matches for both axis.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357370/image.jpeg)
I have already checked the following discussion: https://de.mathworks.com/matlabcentral/answers/368921-yyaxis-change-ylim-for-both-axes
Thank you very much for your inputs!!
0 个评论
采纳的回答
Abdolkarim Mohammadi
2020-9-7
编辑:Abdolkarim Mohammadi
2020-9-7
You should set ylim() for each axes separately. For example:
x = linspace (0, 6, 51)';
y1 = sin (x);
y2 = cos (x);
yyaxis ('left');
plot (x,y1);
ylim ([-2,2]);
yyaxis ('right');
plot (x,y2);
ylim ([-6,6]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357400/image.jpeg)
4 个评论
Abdolkarim Mohammadi
2020-9-7
编辑:Abdolkarim Mohammadi
2020-9-7
ylim() only affects the current axis. When the command yyaxis(AA,'right') is executed, all of the future commands (including ylim()) affect the right yyaxis. You have to do this manually because the scale of your data for the left yyaxis and the right yyaxis differs significantly. The left yyaxis and the right yyaxis are separate and the ruler scale in one side does not affect the one on the other side.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!