FuncScale¶
- class FuncScale(arg, invert=False, parent_scale=None, major_locator=None, minor_locator=None, major_formatter=None, minor_formatter=None)[source]¶
Bases:
proplot.scale._Scale
,matplotlib.scale.ScaleBase
Axis scale composed of arbitrary forward and inverse transformations.
- Parameters
arg (
callable()
,2-tuple
ofcallable()
, orScaleBase
) – The transform used to translate units from the parent axis to the secondary axis. Input can be as follows:A single function that accepts a number and returns some transformation of that number. If you do not provide the inverse, the function must be linear or involutory. For example, to convert Kelvin to Celsius, use
ax.dualx(lambda x: x - 273.15)
. To convert kilometers to meters, useax.dualx(lambda x: x * 1e3)
.A 2-tuple of such functions. The second function must be the inverse of the first. For example, to apply the square, use
ax.dualx((lambda x: x**2, lambda x: x**0.5))
. Again, if the first function is linear or involutory, you do not need to provide the second!A scale specification interpreted by the
Scale
constructor function. The forward transformation, inverse transformation, and default axis locators and formatters are borrowed from the resultingScaleBase
instance. For example, to apply the inverse, useax.dualx('inverse')
. To apply the base-10 exponential function, useax.dualx(('exp', 10))
.
invert (
bool
, optional) – IfTrue
, the forward and inverse functions are swapped. Used when drawing dual axes.parent_scale (
ScaleBase
) – The axis scale of the “parent” axis. Its forward transform is applied to theFuncTransform
. Used when drawing dual axes.major_locator, minor_locator (
Locator
, optional) – The default major and minor locator. By default these are borrowed fromtransform
. Iftransform
is not an axis scale, they are the same asLinearScale
.major_formatter, minor_formatter (
Formatter
, optional) – The default major and minor formatter. By default these are borrowed fromtransform
. Iftransform
is not an axis scale, they are the same asLinearScale
.
Attributes Summary
The registered scale name