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에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!