
    l0j                     2   d Z ddlmZ ddlZddlmZmZ ddlmZ	 ddl
mZ ddlmZ ddlmZ ddlmZ ej        d	         Zd
 Z G d de          Z e e                      Z e                                e            ee          Z ee          ZdS )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                  *   i t           } t          j                    D ]l\  }}d|v rt          j        ||t
                    nDd|v rt          j        |d         |          n%t          j                            ||t
                    | |<   mddddd}|                                D ]+\  }}| |                                         }||_	        || |<   ,t          |                                           D ] }|                                }|| |j	        <   !| S )zw
    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           P/home/wildlama/miniconda3/envs/lam/lib/python3.11/site-packages/matplotlib/cm.py_gen_cmap_registryr(       s6   
 Fkmm L L
d }} *4x@@@ 4 !$x.$777*44T4JJ 	t    G !(  }m$))++	u V]]__%% ! !}} tyM    c                   P    e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	d
dZ
d Zd ZdS )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)
    c                 <    || _         t          |          | _        d S N)_cmapstuple_builtin_cmaps)selfr   s     r'   __init__zColormapRegistry.__init__Z   s    #Ellr)   c                 l    t          j        | j        |t                    }|                                S )N)colormap
_error_cls)r   getitem_checkedr.   KeyErrorr   )r1   itemr%   s      r'   __getitem__zColormapRegistry.__getitem__^   s)    #DK$8TTTyy{{r)   c                 *    t          | j                  S r-   )iterr.   r1   s    r'   __iter__zColormapRegistry.__iter__b   s    DK   r)   c                 *    t          | j                  S r-   )lenr.   r<   s    r'   __len__zColormapRegistry.__len__e   s    4;r)   c                 F    dd                     d | D                       z   S )Nz'ColormapRegistry; available colormaps:
z, c              3   "   K   | ]
}d | d V  dS )'N ).0r   s     r'   	<genexpr>z+ColormapRegistry.__str__.<locals>.<genexpr>j   s*      77$+d+++777777r)   )joinr<   s    r'   __str__zColormapRegistry.__str__h   s-    :		77$777778 	9r)   c                      t          |           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)``.
        )r   r<   s    r'   __call__zColormapRegistry.__call__l   s     Dzzr)   NF)r   forcec                ~   t          j        t          j        |           |p|j        }|| v rI|st          d| d          || j        v rt          d|d          t          j        d|d           |                                | j	        |<   | j	        |         j        |k    r|| j	        |         _        dS dS )	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   
ValueErrorr0   warn_externalr   r.   )r1   r%   r   rK   s       r'   registerzColormapRegistry.registerv   s   2 	foD9999 ty4<< > !GGGGI I I,,,  "=$("= "= "= > > >   Ct  C  C  C D D D !IIKKD ;t!T))%)DK""" *)r)   c                 t    || j         v rt          d|d          | j                            |d           dS )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)r0   rP   r.   pop)r1   r   s     r'   
unregisterzColormapRegistry.unregister   sV    6 4&&& )$ ) ) ) * * *d#####r)   c           	      B   || t           j        d                  S t          |t          j                  r|S t          |t
                    r0t          j        t          t                    |           | |         S t          dd|dt          |           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
        Nz
image.cmaprM   z<get_cmap expects None or an instance of a str or Colormap . zyou passed z	 of type )mplrcParams
isinstancer   rO   strr   check_in_listsorted
_colormaps	TypeErrortype)r1   r%   s     r'   get_cmapzColormapRegistry.get_cmap   s    " <\233 dFO,, 	KdC   	vj11====:J7$774::778
 
 	
r)   )__name__
__module____qualname____doc__r2   r9   r=   r@   rH   rJ   rR   rU   r`   rD   r)   r'   r+   r+   B   s         .+ + +  ! ! !     9 9 9   &* 0* 0* 0* 0* 0*d$ $ $@
 
 
 
 
r)   r+   )rd   collections.abcr   
matplotlibrW   r   r   matplotlib.colorizerr   ScalarMappablematplotlib._cmr   matplotlib._cm_listedr   r   matplotlib._cm_multivarr	   multivar_cmapsmatplotlib._cm_bivarbivar_cmapsrX   r   r(   r+   r]   globalsupdate_multivar_colormaps_bivar_colormapsrD   r)   r'   <module>rs      sP     $ # # # # #     # # # # # # # # B B B B B B             7 7 7 7 7 7 C C C C C C 5 5 5 5 5 5 <$  Dd
 d
 d
 d
 d
w d
 d
 d
T 002233
 		     &&~66 ##K00   r)   