FuncScale
- class FuncScale(transform=None, invert=False, parent_scale=None, **kwargs)[source]
Bases:
_Scale,ScaleBaseAxis scale composed of arbitrary forward and inverse transformations.
- Parameters:
transform (
callable(),2-tupleofcallable(), 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
Scaleconstructor function. The transform and default locators and formatters are borrowed from the resultingScaleBaseinstance. 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, default:LinearScale) – The axis scale of the “parent” axis. Its forward transform is applied to theFuncTransform.major_locator, minor_locator (
locator-spec, optional) – The default major and minor locator. Passed to theLocatorconstructor 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 theFormatterconstructor 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.
See also
ultraplot.constructor.Scale,ultraplot.axes.CartesianAxes.dualx,ultraplot.axes.CartesianAxes.dualyAttributes Summary
The registered scale name
Attributes Documentation
- name = 'function'
The registered scale name