How to align the two axes in one figure

7 visualizaciones (últimos 30 días)
feng wei
feng wei el 25 de Mzo. de 2016
Comentada: Brandon Eidson el 27 de Feb. de 2020
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 comentarios
Walter Roberson
Walter Roberson el 30 de Mzo. de 2016
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 el 30 de Mzo. de 2016
Ubuntu - 2015b

Iniciar sesión para comentar.

Respuestas (1)

Robert
Robert el 30 de Mzo. de 2016
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 comentario
Brandon Eidson
Brandon Eidson el 27 de Feb. de 2020
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by