FuncScale

class FuncScale(transform=None, invert=False, parent_scale=None, **kwargs)[source]

Bases: _Scale, ScaleBase

Axis scale composed of arbitrary forward and inverse transformations.

Parameters
  • transform (callable(), 2-tuple of callable(), or scale-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, use ax.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 resulting ScaleBase instance. For example, to apply the inverse, use ax.dualx('inverse'). To apply the base-10 exponential, use ax.dualx(('exp', 10)).

  • invert (bool, optional) – If True, 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 the FuncTransform.

  • major_locator, minor_locator (locator-spec, optional) – The default major and minor locator. Passed to the Locator 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 from parent_scale.

  • major_formatter, minor_formatter (formatter-spec, optional) – The default major and minor formatter. Passed to the Formatter 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 from parent_scale.