matplotlib 3.5.1

Other ParametersParametersReturnsWarningsBackRef
secondary_yaxis(self, location, *, functions=None, **kwargs)

For example if we want to have a second scale for the data plotted on the yaxis.

Other Parameters

**kwargs : `~matplotlib.axes.Axes` properties.

Other miscellaneous axes parameters.

Parameters

location : {'top', 'bottom', 'left', 'right'} or float

The position to put the secondary axis. Strings can be 'top' or 'bottom' for orientation='x' and 'right' or 'left' for orientation='y'. A float indicates the relative position on the parent axes to put the new axes, 0.0 being the bottom (or left) and 1.0 being the top (or right).

functions : 2-tuple of func, or Transform with an inverse

If a 2-tuple of functions, the user specifies the transform function and its inverse. i.e. functions=(lambda x: 2 / x, lambda x: 2 / x) would be an reciprocal transform with a factor of 2.

The user can also directly supply a subclass of .transforms.Transform so long as it has an inverse.

See /gallery/subplots_axes_and_figures/secondary_axis for examples of making these conversions.

Returns

ax : axes._secondary_axes.SecondaryAxis

Add a second y-axis to this Axes.

Warnings

Examples

Add a secondary Axes that converts from radians to degrees

.. plot:: 
    

fig, ax = plt.subplots() ax.plot(range(1, 360, 5), range(1, 360, 5)) ax.set_ylabel('degrees') secax = ax.secondary_yaxis('right', functions=(np.deg2rad, np.rad2deg)) secax.set_ylabel('radians')

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.axes._secondary_axes.SecondaryAxis.__init__

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/axes/_axes.py#564
type: <class 'function'>
Commit: