
    
3j                        S r SSKJr  SSKrSSKJrJr  SSKJr	  SSK
Jr  SSKJr  SSKJr  SSKJr  \R(                  S	   rS
 r " S S\5      r\" \" 5       5      r\" 5       R5                  \5        \" \5      r\" \5      rg)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)_apicolors)_ScalarMappable)datad)cmaps)cmap_familiesz	image.lutc                     0 [         En [        R                  " 5        Hl  u  pSU;   a  [        R                  " X[
        5      OCSU;   a  [        R                  " US   U5      O#[        R                  R                  X[
        5      X'   Mn     SSSSS.nUR                  5        H!  u  pEX   R                  5       nXFl	        X`U'   M#     [        U R                  5       5       H!  nUR                  5       nXpUR                  '   M#     U $ )zk
Generate a dict mapping standard colormap names to standard colormaps, as
well as the reversed colormaps.
redlistedgray	gist_gray	gist_yargGreys)grey	gist_grey	gist_yergGrays)cmaps_listedr   itemsr   LinearSegmentedColormap_LUTSIZEListedColormap	from_listcopynamelistvaluesreversed)cmap_dr   specaliasesaliasoriginal_namecmaprmaps           G/home/wildlama/miniconda3/lib/python3.13/site-packages/matplotlib/cm.py_gen_cmap_registryr(       s    
 Fkkm
 } **4x@ 4 !!$x.$7**44TJ 	 $   G !($))+	u !0 V]]_%}} tyy & M    c                   X    \ rS rSrSrS rS rS rS rS r	S r
S	S
S.S jrS rS rSrg	)ColormapRegistryB   a  
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)
c                 0    Xl         [        U5      U l        g N)_cmapstuple_builtin_cmaps)selfr   s     r'   __init__ColormapRegistry.__init__Z   s    #Elr)   c                 j    [         R                  " U R                  U[        S9nUR	                  5       $ )N)colormap
_error_cls)r   getitem_checkedr/   KeyErrorr   )r2   itemr%   s      r'   __getitem__ColormapRegistry.__getitem__^   s&    ##DKK$8Tyy{r)   c                 ,    [        U R                  5      $ r.   )iterr/   r2   s    r'   __iter__ColormapRegistry.__iter__b   s    DKK  r)   c                 ,    [        U R                  5      $ r.   )lenr/   r?   s    r'   __len__ColormapRegistry.__len__e   s    4;;r)   c                 8    SSR                  S U  5       5      -   $ )Nz'ColormapRegistry; available colormaps:
z, c              3   .   #    U  H  nS U S 3v   M     g7f)'N ).0r   s     r'   	<genexpr>+ColormapRegistry.__str__.<locals>.<genexpr>j   s     7$$AdV1+$s   )joinr?   s    r'   __str__ColormapRegistry.__str__h   s!    :		7$778 	9r)   c                     [        U 5      $ )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)``.
)r   r?   s    r'   __call__ColormapRegistry.__call__l   s     Dzr)   NF)r   forcec                   [         R                  " [        R                  US9  U=(       d    UR                  nX ;   aP  U(       d  [        SU S35      eX R                  ;   a  [        SU< S35      e[         R                  " SU< S35        UR                  5       U R                  U'   U R                  U   R                  U:w  a  X R                  U   l        gg)	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%   zA colormap named "z" is already registered.z Re-registering the builtin cmap z is not allowed.zOverwriting the cmap z" that was already in the registry.N)
r   check_isinstancer   Colormapr   
ValueErrorr1   warn_externalr   r/   )r2   r%   r   rS   s       r'   registerColormapRegistry.registerv   s    2 	fooD9 tyy< !(.FGI I,,, !C$(8+;"= > > !6th ?C  C D !IIKD ;;t!!T)%)KK" *r)   c                 z    XR                   ;   a  [        SU< S35      eU R                  R                  US5        g)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.
zcannot unregister z which is a builtin colormap.N)r1   rX   r/   pop)r2   r   s     r'   
unregisterColormapRegistry.unregister   s@    6 &&&1$ :) ) * *d#r)   c           	      (   Uc  U [         R                  S      $ [        U[        R                  5      (       a  U$ [        U[
        5      (       a&  [        R                  " [        [        5      US9  X   $ [        SSU< S[        U5       3-   5      e)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
z
image.cmaprU   z<get_cmap expects None or an instance of a str or Colormap . zyou passed z	 of type )mplrcParams
isinstancer   rW   strr   check_in_listsorted
_colormaps	TypeErrortype)r2   r%   s     r'   get_cmapColormapRegistry.get_cmap   s    " <\233 dFOO,,KdC  vj1=:J$4:,78
 	
r)   )r1   r/   )__name__
__module____qualname____firstlineno____doc__r3   r;   r@   rD   rN   rQ   rZ   r^   rj   __static_attributes__rI   r)   r'   r+   r+   B   s=    .+! 9 &* 0*d$@
r)   r+   )rp   collections.abcr   
matplotlibra   r   r   matplotlib.colorizerr   ScalarMappablematplotlib._cmr   matplotlib._cm_listedr   r   matplotlib._cm_multivarr	   multivar_cmapsmatplotlib._cm_bivarbivar_cmapsrb   r   r(   r+   rg   globalsupdate_multivar_colormaps_bivar_colormapsrI   r)   r'   <module>r      s     $  # B   7 C 5 <<$Dd
w d
T 023
 	   &~6 #K0 r)   