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, useax.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 theScale
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, useax.dual%(x)s(plot.Scale('inverse'))
. To apply the base-10 exponential function, useax.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 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
.smart_bounds (bool, optional) – Whether “smart bounds” are enabled by default. If not
None
, this is passed toset_smart_bounds
whenset_default_locators_and_formatters
is called. By default these are borrowed fromtransform
.
Attributes Summary
The registered scale name.