matplotlib.axes.Axes.twiny#

Axes.twiny(axes_class=None,**kwargs)[source]#

Create a twin Axes sharing the yaxis.

Create a new Axes with an invisible y-axis and an independentx-axis positioned opposite to the original one (i.e. at top). They-axis autoscale setting will be inherited from the original Axes.To ensure that the tick marks of both x-axes align, seeLinearLocator.

Parameters:
axes_classsubclass type ofAxes, optional

Theaxes.Axes subclass that is instantiated. This parameteris incompatible withprojection andpolar. Seeaxisartist for examples.

By default,Axes is used.

Added in version 3.11.

kwargsdict

The keyword arguments passed toFigure.add_subplot orFigure.add_axes.

Added in version 3.11.

Returns:
Axes

The newly created Axes instance

Notes

For those who are 'picking' artists while using twiny, pickevents are only called for the artists in the top-most Axes.

Examples usingmatplotlib.axes.Axes.twiny#

Plots with different scales

Plots with different scales