Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Create chart with two y-axes

`yyaxis left`

`yyaxis right`

`yyaxis(ax,___)`

`yyaxis `

activates
the side of the current axes associated with the left `left`

*y*-axis.
Subsequent graphics commands target the left side. If the current
axes do not include two *y*-axes, then this command
adds a second *y*-axis. If there are no axes, then
this command first creates them.

`yyaxis `

activates
the side of the current axes associated with the right `right`

*y*-axis.
Subsequent graphics commands target the right side. If the current
axes do not include two *y*-axes, then this command
adds a second *y*-axis. If there are no axes, then
this command first creates them.

When working with two y-axes, you cannot:

Rotate the axes (2-D view only).

Pin annotations.

Copy the axes object using

`copyobj`

.

Grid lines correspond with the tick mark locations along the left

*y*-axis.To determine which side of the axes is active, query the

`YAxisLocation`

property for the`Axes`

object. The property is set to`'left'`

when the left side is active and`'right'`

when the right side is active. The`YAxisLocation`

property for an`Axes`

object with two*y*-axes is read only.To clear the active side, use

`cla`

. To clear both sides of the axes and remove the right*y*-axis, use`cla reset`

. Alternatively, you can wait to clear both sides and remove the right*y*-axis until the next plotting command by setting the`NextPlot`

property of the`Axes`

object to`'replaceall'`

.

Was this topic helpful?