FuncScale

class FuncScale(arg, invert=False, parent_scale=None, major_locator=None, minor_locator=None, major_formatter=None, minor_formatter=None, smart_bounds=None)[source]

Bases: proplot.axistools._ScaleBase, matplotlib.scale.ScaleBase

An axis scale comprised of arbitrary forward and inverse transformations.

Parameters
  • arg (function, (function, function), or ScaleBase) – 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.dual%(x)s(lambda x: x - 273.15). To convert kilometers to meters, use ax.dual%(x)s(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.dual%(x)s((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 ScaleBase instance, e.g. a scale returned by the Scale constructor function. The forward transformation, inverse transformation, and default axis locators and formatters are borrowed from the resulting scale class. For example, to apply the inverse, use ax.dual%(x)s(plot.Scale('inverse')). To apply the base-10 exponential function, use ax.dual%(x)s(plot.Scale('exp', 10)).

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

  • major_locator, minor_locator (Locator, optional) – The default major and minor locator. By default these are borrowed from transform. If transform is not an axis scale, they are the same as LinearScale.

  • major_formatter, minor_formatter (Formatter, optional) – The default major and minor formatter. By default these are borrowed from transform. If transform is not an axis scale, they are the same as LinearScale.

  • smart_bounds (bool, optional) – Whether “smart bounds” are enabled by default. If not None, this is passed to set_smart_bounds when set_default_locators_and_formatters is called. By default these are borrowed from transform.

Attributes Summary

name

The registered scale name.