howto align two sets of axes each with left and right Y-axes and labels?

7 views (last 30 days)
i had a previous question on something similar but this is more of the root of the problem:
axW = 0.5;
figure;a1=axes('outerposition',[0 0 axW 1],'ylim',[0 100]);a2=axes('outerposition',[axW 0 axW 1],'ylim',[0 100]);
a1b = axes('outerposition',[0 0 axW 1],'yaxislocation','right');
a2b = axes('outerposition',[axW 0 axW 1],'yaxislocation','right');
ylabel(a1,'a1');ylabel(a1b,'a1b');ylabel(a2,'a2');ylabel(a2b,'a2b');
above produces this:
i understand why the axes no longer line up (a1 and a1b).
The question is: how do i get them to line up without any of the labels from going out of the figure and without them going outside of their original 'outerposition'?
keep in mind that i may have any number of plots across the page, and any ylim settings, any number of ylabel lines, etc.
do i have to calc the difference btwn the right most edge of a1 and a1b and correct 'position' of a1 that way? that might work, hoping for a better/easier/automated/matlabdoesit way.
thanks in advance!

Answers (0)

Community Treasure Hunt

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

Start Hunting!