Why does changing the X-axis in a plot generated with the PLOTYY function corrupt the X-axis in MATLAB?

1 view (last 30 days)
Why does changing the X-axis in a plot generated with the PLOTYY function corrupt the X-axis in MATLAB?
I generated a plot using the PLOTYY function. When I try to change the X-axis using the AXIS function or the XLIM function, it becomes corrupted. It appears to have two different sets of numbers and tick marks.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The X-axis is not actually corrupted. The PLOTYY function generates two different axes, one on top of the other. The AXIS and XLIM functions will only modify the axis that was most recently used, so the unmodified axis appears to corrupt the X-axis labels. The object handles will have to be used to modify both axes at once.
For example,
ax = plotyy([0 1 2],[1 0 1],[0 1 2], [5 10 15])
xlim(ax(1),[-1 3])
% the xaxis will be corrupted at this step
xlim(ax(2),[-1 3])

More Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!