FuncScale¶
- class FuncScale(transform, invert=False, parent_scale=None, **kwargs)[source]¶
Bases:
proplot.scale._Scale
,matplotlib.scale.ScaleBase
Axis scale composed of arbitrary forward and inverse transformations.
- Parameters
transform (
callable()
,2-tuple
ofcallable()
, orscale-spec
) – The transform used to translate units from the parent axis to the secondary axis. Input can be as follows:A single linear or involutory function that accepts a number and returns some transformation of that number. 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 arbitrary functions. This should only be used if your functions are non-linear and non-involutory. 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))
.A scale specification passed to the
Scale
constructor function. The transform and default locators and formatters are borrowed from the resultingScaleBase
instance. For example, to apply the inverse, useax.dualx('inverse')
. To apply the base-10 exponential, 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
. Default isLinearScale
.major_locator, minor_locator (
locator-spec
, optional) – The default major and minor locator. Passed to theLocator
constructor function. By default, these are the same as the default locators on the input transform. If the input transform was not an axis scale, these are borrowed fromparent_scale
.major_formatter, minor_formatter (
formatter-spec
, optional) – The default major and minor formatter. Passed to theFormatter
constructor function. By default, these are the same as the default formatters on the input transform. If the input transform was not an axis scale, these are borrowed fromparent_scale
.