Subplots with equal "nice" y-axes -- is there a function?
显示 更早的评论
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
采纳的回答
更多回答(3 个)
Jan
2012-3-13
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 个评论
Jorge MARTINEZ
2016-9-16
移动:DGM
2024-11-7
anyways, Jan, your solution works like a charm... as usual ;)
Brett Davenport
2018-4-8
编辑:Brett Davenport
2018-4-8
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
Jorge MARTINEZ
2016-9-16
4 个投票
what about "linkaxes" function?
2 个评论
Brett Davenport
2018-4-8
Perfect
David Bennetts
2020-6-7
Worked perfectly for me too. I had to add it add the end of the script after all of the subplot calls.
类别
在 帮助中心 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!