| [ Web Proxy ] |
| Viewing: https://matplotlib.org/users/../api/_as_gen/../_as_gen/matplotlib.axes.Axes.secondary_xaxis.html | [Back] [Original] |
Add a second x-axis to this Axes.
This axis is typically used to display a second x-scale for the data plotted on the Axes.
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).
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. Both functions must accept
numpy arrays as input.
The user can also directly supply a subclass of
transforms.Transform so long as it has an inverse.
See Secondary Axis for examples of making these conversions.
Transform, optionalIf specified, location will be placed relative to this transform (in the direction of the axis) rather than the parent's axis. i.e. a secondary x-axis will use the provided y transform and the x transform of the parent.
Added in version 3.9.
The returned Axes is overlaid on top of the original Axes and all
components except for the complementary axis are hidden. You may modify
the complementary axis, e.g. by setting ticks or an axis label. However,
it is not designed to hold data, so that you should not call any
plotting methods on it. Its limits are derived from the parent Axes via
the specified transformation, and setting limits on the secondary axis
(e.g., via set_xlim or set_ylim) has no effect.
Axes properties.Other miscellaneous Axes parameters.
Warning
This method is experimental as of 3.1, and the API may change.
Examples
The main axis shows frequency, and the secondary axis shows period.
(Source code, 2x.png, png)
[]
To add a secondary axis relative to your data, you can pass a transform to the new axis.
(Source code, 2x.png, png)
[]
matplotlib.axes.Axes.secondary_xaxis#| Web Proxy Viewer | New URL | Original Page |