rL idZddlmZddlmZddlZddlmZddlm Z Gdde Z d Z Gd d Z Gd d ZGddeZGddeZeZeee<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__V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/units.pyrr4sr rctj|r?|D]9}|tjurt |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)npiterablermasked isinstancerr)xthisxs r_is_natively_supportedr8si  {{1~ PE !eV,OZw5O1O O P !V$CZ7-C)CCr ceZdZdZ ddZy)AxisInfoz Information to support default axis labeling, tick labeling, and limits. An instance of this class must be returned by `ConversionInterface.axisinfo`. NcX||_||_||_||_||_||_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)majlocminlocmajfmtminfmtlabeldefault_limits)selfrrrrrrs r__init__zAxisInfo.__init__Os/*     ,r )NNNNNN)r r r __doc__r!r r rrrHs ,015 $-r rc@eZdZdZedZedZedZy)ConversionInterfacez The minimal interface for a converter to take custom data types (or sequences) and convert them to values Matplotlib can use. cy)zrQss(T i  D !-!-H62*24tB :$&r