How to align the two axes in one figure

조회 수: 8 (최근 30일)
feng wei
feng wei 2016년 3월 25일
댓글: Brandon Eidson 2020년 2월 27일
I have a problem with aligning two axes in one figure. the two y axes are well aligned while the fig window is maxmized, but not in correct position if the fig window is not maximized.
  댓글 수: 7
Walter Roberson
Walter Roberson 2016년 3월 30일
That aligns for me in R2014a on OS-X. If you are using R2014b or newer then you might get something different than I do.
Ced
Ced 2016년 3월 30일
Ubuntu - 2015b

댓글을 달려면 로그인하십시오.

답변 (1개)

Robert
Robert 2016년 3월 30일
In addition to plotyy as mentioned in the comments, I sometimes use (in R2015a) the following command to add a listener to my top axis that edits the position of my bottom axis to match. For handles ax1 below and ax2 on top:
addlistener(ax2,'MarkedClean',@(varargin)set(ax1,'Position',get(ax2,'Position')));
(This assumes that both axes use the same units for position.)
  댓글 수: 1
Brandon Eidson
Brandon Eidson 2020년 2월 27일
This is excellent. I have found no other way to sync up two y-axes that are on the same side for two different x-axes. Your line of code plus making the ylim's the same was key. Thanks, Robert.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by