MATLAB: Offset between 2 axes when using plotyy

axes positionplotyy

Hi everyone, I have a problem of plotyy display. In fullscreen mode, 2 axes are superimposed correctly, when I try to modify some details with "plot tools and dock figure" (eg: label size) and re-display the figure in fullscreen mode, there is an offset between 2 axes (cf. fig). I would like to know how to re-fix axes position?
Kind regards, Winn

Best Answer

Never seen that symptom before; then again I don't use the plot tools menu much.
It looks like somehow dragged the RH axes lower position or perhaps there's an automated adjustment of spacing when change the font size drastically.
In modifying plotyy properties, one needs must remember there are two independent axes overlaid so have to make sure whatever happens to change the position or properties of one are reflected on the other relative to positions, x-ticks, etc., ...
To fix this, retrieve the 'position' coordinates of each axes and reset the bottom and height values (2nd and 4th entries) of the RH axes to those of the left. I'll assume you have the two axes handles as hA --
p1=get(hA(1),'position'); % LH axes position
p2=get(hA(2),'position'); % and RH...
p2(2)=p1(2); p2(4)=p1(4); % fixup the RH bottom, height
set(hA(2),'position',p2) % and reset
ADDENDUM
Actually, the above is far more complex than needs be--simply reset the RH to the LH values (or vice versa, depending on which one wants to keep)--
set(hA(2),'position',get(hA(1),'position'))