Subplots with equal "nice" y-axes -- is there a function?
Ältere Kommentare anzeigen
Hello,
I thought I had seen a function somewhere that would modify subplots so that each of the plots would have the same scale (i.e., ylim) and all of them fit nicely. Kind of like "auto" for the subplot with the highest amplitude applied to all of the subplots.
Is there such a function, or option for an existing function?
Thanks
Akzeptierte Antwort
Weitere Antworten (3)
Jan
am 13 Mär. 2012
allYLim = get(AxesHandle, {'YLim'});
allYLim = cat(2, allYLim{:});
set(AxesHandle, 'YLim', [min(allYLim), max(allYLim)]);
The curly braces around 'YLim' in the get command are needed, if AxesHandle is a scalar.
1 Kommentar
Jorge MARTINEZ
am 16 Sep. 2016
Verschoben: DGM
am 7 Nov. 2024
anyways, Jan, your solution works like a charm... as usual ;)
Brett Davenport
am 8 Apr. 2018
Bearbeitet: Brett Davenport
am 8 Apr. 2018
subplot(1,2,1);plot(t,x);
y1=ylim %gets current limits
subplot(1,2,2);plot(t2,x2);
ylim(y1) %sets limits to that of first subplot
1 Kommentar
Nick
am 7 Nov. 2024
smooth
Jorge MARTINEZ
am 16 Sep. 2016
4 Stimmen
what about "linkaxes" function?
2 Kommentare
Brett Davenport
am 8 Apr. 2018
Perfect
David Bennetts
am 7 Jun. 2020
Worked perfectly for me too. I had to add it add the end of the script after all of the subplot calls.
Kategorien
Mehr zu Axis Labels finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!