How to align xaxis when using yyaxis

2 visualizzazioni (ultimi 30 giorni)
Nicolas
Nicolas il 14 Nov 2016
Modificato: dpb il 16 Nov 2016
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 Commento
dpb
dpb il 14 Nov 2016
Modificato: dpb il 16 Nov 2016
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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Graphics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by