How to align xaxis when using yyaxis

2 次查看(过去 30 天)
Nicolas
Nicolas 2016-11-14
编辑: dpb 2016-11-16
I would like to align the yaxis automatically of two plot when using yyaxis. Here's an example of the problem:
time = 0:1:10;
s=sawtooth(time);
v=-2:1:8;
yyaxis('left');
plot(time,s);
ylabel('s');
yyaxis('right');
plot(time,v);
ylabel('v');
When doing this, the y=0 of the left signal is align with the y=3 of the right signal in yaxis. How could it be both align on y=0? I still want to matlab to decide of the tick, min and max value of the yaxis, I just want the zeros to be align.
  1 个评论
dpb
dpb 2016-11-14
编辑:dpb 2016-11-16
Can't have Matlab be automagic in choosing the limits and still force the origin to be someplace specific--too many constraints with too few variables.
You'll have to do this by computing consistent ranges from those chosen and figure out what new scaling on ticks or ranges would be required to make the origins match up, sorry...
ADDENDUM What you were probably looking/wishing for is a property to set the origin location arbitrarily--unfortunately, the only property values yet implemented remain '[origin|bottom|top]' for y-axis and similarly for x. A general value isn't allowed.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by