How can I modify the Y limits of the axes created by PLOTYY in my MATLAB figure?
42 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 27 Jun. 2009
Bearbeitet: MathWorks Support Team
am 14 Mär. 2016
How can I modify the Y limits of the axes created by PLOTYY in my MATLAB figure?
I've plotted two different data series together, using PLOTYY. I would now like to change the Y limits of the axes. What commands can I use to change the limits?
Akzeptierte Antwort
MathWorks Support Team
am 14 Mär. 2016
The limits (and Y ticks) are automatically calculated by the PLOTYY function, so that they are aligned for both sets of data. However, you can modify them by changing the axes' YLim values.
x = 1:10;
y1 = sin(x);
y2 = 10*cos(x);
[ax,h1,h2] = plotyy(x,y1,x,y2);
set(ax(1),'YLim',[-2 2])
set(ax(2),'YLim',[-15 15])
However, now that the Y limits are changed, you may want to change some other properties of the axes that affect its appearance. One option is to set the Box property for the first axes to 'off', to avoid extra ticks on the right side. The extra ticks that appear were previously aligned with the ticks from the second axes. Try the following code:
set(ax(1),'Box','off')
To change the locations of the Y tick marks as well:
set(ax(1),'YTick',[-2:.5:2])
set(ax(2),'YTick',[-15:5:15])
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Two y-axis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!