rL in(FdZddlmZddlZddlmZmZddlmZ ddl m Z ddl m ZddlmZddlm Zej(d Zd ZGd d eZeeZej5eeeZeeZej:d ddddZdZy)a| Builtin colormaps, colormap handling utilities, and the `ScalarMappable` mixin. .. seealso:: :doc:`/gallery/color/colormap_reference` for a list of builtin colormaps. :ref:`colormap-manipulation` for examples of how to make colormaps. :ref:`colormaps` an in-depth discussion of choosing colormaps. :ref:`colormapnorms` for more details about data normalization. )MappingN)_apicolors)_ScalarMappable)datad)cmaps) cmap_familiesz image.lutc it}tjD]i\}}d|vrtj||t nAd|vrtj |d|n$tjj||t ||<kddddd}|jD]$\}}||j}||_ |||<&t|jD]!}|j}|||j<#|S)zw Generate a dict mapping standard colormap names to standard colormaps, as well as the reversed colormaps. redlistedgray gist_gray gist_yargGreys)grey gist_grey gist_yergGrays) cmaps_listedritemsrLinearSegmentedColormap_LUTSIZEListedColormap from_listcopynamelistvaluesreversed)cmap_drspecaliasesalias original_namecmaprmaps S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/cm.py_gen_cmap_registryr( s  FkkmL d}  * *4x @4  ! !$x.$ 7  * * 4 4T4 J t L   G!( }m$))+ u  V]]_%!}} tyy! McNeZdZdZdZdZdZdZdZdZ dd d d Z d Z d Z y)ColormapRegistrya Container for colormaps that are known to Matplotlib by name. The universal registry instance is `matplotlib.colormaps`. There should be no need for users to instantiate `.ColormapRegistry` themselves. Read access uses a dict-like interface mapping names to `.Colormap`\s:: import matplotlib as mpl cmap = mpl.colormaps['viridis'] Returned `.Colormap`\s are copies, so that their modification does not change the global definition of the colormap. Additional colormaps can be added via `.ColormapRegistry.register`:: mpl.colormaps.register(my_colormap) To get a list of all registered colormaps, you can do:: from matplotlib import colormaps list(colormaps) c2||_t||_yN)_cmapstuple_builtin_cmaps)selfrs r'__init__zColormapRegistry.__init__Zs #Elr)cv |j|jS#t$rt|ddwxYw)Nz is not a known colormap name)r.rKeyError)r1items r' __getitem__zColormapRegistry.__getitem__^sF O;;t$))+ + OdX%BCD$ N Os8c,t|jSr-)iterr.r1s r'__iter__zColormapRegistry.__iter__dsDKK  r)c,t|jSr-)lenr.r9s r'__len__zColormapRegistry.__len__gs4;;r)c8ddjd|DzS)Nz'ColormapRegistry; available colormaps: z, c3(K|] }d|d yw)'N).0rs r' z+ColormapRegistry.__str__..ls7$AdV1+7s)joinr9s r'__str__zColormapRegistry.__str__js!: 7$778 9r)ct|S)z Return a list of the registered colormap names. This exists only for backward-compatibility in `.pyplot` which had a ``plt.colormaps()`` method. The recommended way to get this list is now ``list(colormaps)``. )rr9s r'__call__zColormapRegistry.__call__nsDzr)NF)rforcectjtj||xs |j}||vrG|st d|d||j vrt d|dtjd|d|j|j|<|j|j|k7r||j|_yy) a Register a new colormap. The colormap name can then be used as a string argument to any ``cmap`` parameter in Matplotlib. It is also available in ``pyplot.get_cmap``. The colormap registry stores a copy of the given colormap, so that future changes to the original colormap instance do not affect the registered colormap. Think of this as the registry taking a snapshot of the colormap at registration. Parameters ---------- cmap : matplotlib.colors.Colormap The colormap to register. name : str, optional The name for the colormap. If not given, ``cmap.name`` is used. force : bool, default: False If False, a ValueError is raised if trying to overwrite an already registered name. True supports overwriting registered colormaps other than the builtin colormaps. r%zA colormap named "z" is already registered.z Re-registering the builtin cmap z is not allowed.zOverwriting the cmap z" that was already in the registry.N) rcheck_isinstancerColormapr ValueErrorr0 warn_externalrr.)r1r%rrHs r'registerzColormapRegistry.registerxs2 fooD9 tyy 4<!(.FGII,,, !C$(8+;"=>>   !6th?C C D!IIK D ;;t  ! !T )%)DKK  " *r)cv||jvrtd|d|jj|dy)a Remove a colormap from the registry. You cannot remove built-in colormaps. If the named colormap is not registered, returns with no error, raises if you try to de-register a default colormap. .. warning:: Colormap names are currently a shared namespace that may be used by multiple packages. Use `unregister` only if you know you have registered that name before. In particular, do not unregister just in case to clean the name before registering a new colormap. Parameters ---------- name : str The name of the colormap to be removed. Raises ------ ValueError If you try to remove a default built-in colormap. zcannot unregister z which is a builtin colormap.N)r0rMr.pop)r1rs r' unregisterzColormapRegistry.unregistersB6 4&& &1$:))* * d#r)c ||tjdSt|tjr|St|t r)t jtt|||Stdd|dt|z)a Return a color map specified through *cmap*. Parameters ---------- cmap : str or `~matplotlib.colors.Colormap` or None - if a `.Colormap`, return it - if a string, look it up in ``mpl.colormaps`` - if None, return the Colormap defined in :rc:`image.cmap` Returns ------- Colormap image.cmaprJz.+O ! 9&*0*d$@ r)r+z3.7z3.11z^``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()`` or ``pyplot.get_cmap()``)removal alternativec|tjd}t|tjr|St j tt|| t|St|j|S)ah Get a colormap instance, defaulting to rc values if *name* is None. Parameters ---------- name : `~matplotlib.colors.Colormap` or str or None, default: None If a `.Colormap` instance, it will be returned. Otherwise, the name of a colormap known to Matplotlib, which will be resampled by *lut*. The default, None, means :rc:`image.cmap`. lut : int or None, default: None If *name* is not already a Colormap instance and *lut* is not None, the colormap will be resampled to have *lut* entries in the lookup table. Returns ------- Colormap rT)r) rUrVrWrrLrrYrZr[ resampled)rluts r'r^r^se0 |||L)$( vj)5 {$$))#..r)ct|tjr|S||ntjd}|t vr$t jtt |tj|S)ao Ensure that we have a `.Colormap` object. For internal use to preserve type stability of errors. Parameters ---------- cmap : None, str, Colormap - if a `Colormap`, return it - if a string, look it up in mpl.colormaps - if None, look up the default color map in mpl.colormaps Returns ------- Colormap rTrJ) rWrrLrUrVr[rrYrZ colormaps)r% cmap_names r' _ensure_cmaprksZ&$( (cll<.HI " 6*-I> == ##r))NN) rbcollections.abcr matplotlibrUrrmatplotlib.colorizerrScalarMappablematplotlib._cmrmatplotlib._cm_listedrrmatplotlib._cm_multivarr multivar_cmapsmatplotlib._cm_bivar bivar_cmapsrVrr(r+r[globalsupdate_multivar_colormaps_bivar_colormaps deprecatedr^rkrAr)r'r{s $#B 7C5 << $Df wf X02 3  &~6#K0  , /  /:$r)