Sometimes we want a secondary axis on a plot, for instance to convert
radians to degrees on the same plot. We can do this by making a child
axes with only one axis visible via axes.Axes.secondary_xaxis and
axes.Axes.secondary_yaxis. This secondary axis can have a different scale
than the main axis by providing both a forward and an inverse conversion
function in a tuple to the functions keyword argument:
See also Plots with different scales for the case
where two scales are not related to one another, but independent.
By default, the secondary axis is drawn in the Axes coordinate space.
We can also provide a custom transform to place it in a different
coordinate space. Here we put the axis at Y = 0 in data coordinates.
Sometime we want to relate the axes in a transform that is ad-hoc from the data, and
is derived empirically. Or, one axis could be a complicated nonlinear function of the
other. In these cases we can set the forward and inverse transform functions to be
linear interpolations from the one set of independent variables to the other.
A final example translates np.datetime64 to yearday on the x axis and
from Celsius to Fahrenheit on the y axis. Note the addition of a
third y axis, and that it can be placed using a float for the
location argument