Files
intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/units.cpython-312.pyc
T

105 lines
7.6 KiB
Plaintext
Raw Normal View History

Ë
†RjãóÒdZddlmZddlmZddlZddlmZddlm Z Gdde
«Z d „Z Gd
d «Z
Gd d
«ZGdde«ZGdde«Ze«Ze«ee<y)aQ
The classes here provide support for using custom classes with
Matplotlib, e.g., those that do not expose the array interface but know
how to convert themselves to arrays. It also supports classes with
units and units conversion. Use cases include converters for custom
objects, e.g., a list of datetime objects, as well as for objects that
are unit aware. We don't assume any particular units implementation;
rather a units implementation must register with the Registry converter
dictionary and provide a `ConversionInterface`. For example,
here is a complete implementation which supports plotting with native
datetime objects::
import matplotlib.units as units
import matplotlib.dates as dates
import matplotlib.ticker as ticker
import datetime
class DateConverter(units.ConversionInterface):
@staticmethod
def convert(value, unit, axis):
"Convert a datetime value to a scalar or array."
return dates.date2num(value)
@staticmethod
def axisinfo(unit, axis):
"Return major and minor tick locators and formatters."
if unit != 'date':
return None
majloc = dates.AutoDateLocator()
majfmt = dates.AutoDateFormatter(majloc)
return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='date')
@staticmethod
def default_units(x, axis):
"Return the default unit for x or None."
return 'date'
# Finally we register our object type with the Matplotlib units registry.
units.registry[datetime.date] = DateConverter()
é)ÚDecimal)ÚNumberN)Úma)Úcbookcó eZdZy)ÚConversionErrorN)Ú__name__Ú
__module__Ú __qualname__©óúS/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/units.pyrr4sØr
rcóðtj|«r?|D]9}|tjurŒt |t
«xrt |t « cSyt |t
«xrt |t « S)zu
Return whether *x* is of a type that Matplotlib natively supports or an
array of objects of such types.
N)ÚnpÚiterablerÚmaskedÚ
isinstancerr)Úthisxs rÚ_is_natively_supportedr8siô 
‡{{1„~àò PˆEØœŸ ™ Ñܘe¤VÓO´ÄwÓ5OÐ1OÒ  Pô
˜!œVÓC¬Z¸¼7Ó-CÐ)CÐCr
cóeZdZdZ ddZy)ÚAxisInfoz©
Information to support default axis labeling, tick labeling, and limits.
An instance of this class must be returned by
`ConversionInterface.axisinfo`.
NcóX||_||_||_||_||_||_y)a:
Parameters
----------
majloc, minloc : Locator, optional
Tick locators for the major and minor ticks.
majfmt, minfmt : Formatter, optional
Tick formatters for the major and minor ticks.
label : str, optional
The default axis label.
default_limits : optional
The default min and max limits of the axis if no data has
been plotted.
Notes
-----
If any of the above are ``None``, the axis will simply use the
default value.
N)ÚmajlocÚminlocÚmajfmtÚminfmtÚlabelÚdefault_limits)Úselfrrrrrrs rÚ__init__zAxisInfo.__init__Os/ð*ˆŒ ؈Œ ؈Œ ؈Œ ؈Œ
Ø,ˆÕr
)NNNNNN)r r
r Ú__doc__r!r r
rrrHsñð ,0Ø15Ø $ô-r
rcó@eZdZdZed«Zed«Zed«Zy)ÚConversionInterfacez
The minimal interface for a converter to take custom data types (or
sequences) and convert them to values Matplotlib can use.
cóy)z<Return an `.AxisInfo` for the axis with the specified units.Nr )ÚunitÚaxiss rÚaxisinfozConversionInterface.axisinforóðr
cóy)z?Return the default unit for *x* or ``None`` for the given axis.Nr )rr's rÚ
default_unitsz!ConversionInterface.default_unitswr)r
có|S)
Convert *obj* using *unit* for the specified *axis*.
If *obj* is a sequence, return the converted sequence. The output must
be a sequence of scalars that can be used by the numpy array layer.
r )Úobjr&r's rÚconvertzConversionInterface.convert|s ðˆ
r
N)r r
r r"Ú staticmethodr(r+r.r r
rr$r$lsCñð
ñóððñóððñóñr
r$có eZdZdZed«Zy)ÚDecimalConverterz,Converter for decimal.Decimal data to float.cóØt|t«r t|«St|tj«rtj
|t¬«St
j
|t¬«S)
Convert Decimals to floats.