
    Mh                     t   S SK Jr  S SKJrJr  S SKrS SKJrJr  S SK	r	S SK
rS SKr
S SKrS SKJr  S SKJr  S SKJr  S SKJs  Jr  \(       a  S SKJr     S       SS	 jjr          SS
 jrSS jr      SS jrSS jr    SS jr SS jr!SS jr"SS jr#S S jr$S!S jr%S!S jr&S"S jr'S#S jr(g)$    )annotations)
CollectionIteratorN)TYPE_CHECKINGcast)MatplotlibColor)find_stack_level)is_list_like)Colormapc                l    [        U[        5      (       a  U$ [        UUUU S9n[        [	        X@S95      $ )a7  
Get standard colors based on `colormap`, `color_type` or `color` inputs.

Parameters
----------
num_colors : int
    Minimum number of colors to be returned.
    Ignored if `color` is a dictionary.
colormap : :py:class:`matplotlib.colors.Colormap`, optional
    Matplotlib colormap.
    When provided, the resulting colors will be derived from the colormap.
color_type : {"default", "random"}, optional
    Type of colors to derive. Used if provided `color` and `colormap` are None.
    Ignored if either `color` or `colormap` are not None.
color : dict or str or sequence, optional
    Color(s) to be used for deriving sequence of colors.
    Can be either be a dictionary, or a single color (single color string,
    or sequence of floats representing a single color),
    or a sequence of colors.

Returns
-------
dict or list
    Standard colors. Can either be a mapping if `color` was a dictionary,
    or a list of colors with a length of `num_colors` or more.

Warns
-----
UserWarning
    If both `colormap` and `color` are provided.
    Parameter `color` will override.
colorcolormap
color_type
num_colorsr   )
isinstancedict_derive_colorslist_cycle_colors)r   r   r   r   colorss        S/var/www/html/env/lib/python3.13/site-packages/pandas/plotting/_matplotlib/style.pyget_standard_colorsr      s?    L %	F f<==    c                    U c  Ub	  [        XS9$ U b+  Ub  [        R                  " S[        5       S9  [	        U 5      $ [        X#S9$ )a  
Derive colors from either `colormap`, `color_type` or `color` inputs.

Get a list of colors either from `colormap`, or from `color`,
or from `color_type` (if both `colormap` and `color` are None).

Parameters
----------
color : str or sequence, optional
    Color(s) to be used for deriving sequence of colors.
    Can be either be a single color (single color string, or sequence of floats
    representing a single color), or a sequence of colors.
colormap : :py:class:`matplotlib.colors.Colormap`, optional
    Matplotlib colormap.
    When provided, the resulting colors will be derived from the colormap.
color_type : {"default", "random"}, optional
    Type of colors to derive. Used if provided `color` and `colormap` are None.
    Ignored if either `color` or `colormap`` are not None.
num_colors : int
    Number of colors to be extracted.

Returns
-------
list
    List of colors extracted.

Warns
-----
UserWarning
    If both `colormap` and `color` are provided.
    Parameter `color` will override.
r   zC'color' and 'colormap' cannot be used simultaneously. Using 'color')
stacklevel)_get_colors_from_colormapwarningswarnr	   _get_colors_from_color_get_colors_from_color_typer   s       r   r   r   P   sS    N }-(II		MMU+- &e,,*:MMr   c              #     #    [        U[        U 5      5      n[        R                  " [        R                  " U 5      U5       Sh  vN   g N7f)zCycle colors until achieving max of `num_colors` or length of `colors`.

Extra colors will be ignored by matplotlib if there are more colors
than needed and nothing needs to be done here.
N)maxlen	itertoolsislicecycle)r   r   
max_colorss      r   r   r      s6      ZV-J	 7DDDs   AAAAc                z    [        U 5      n[        R                  " SSUS9 Vs/ s H
  o2" U5      PM     sn$ s  snf )zGet colors from colormap.r      )num)_get_cmap_instancenplinspace)r   r   cmapr,   s       r   r   r      s9    
 h'D!#Qz!BC!B#DI!BCCCs   8c                ~    [        U [        5      (       a'  U n[        R                  U    n U c  [	        SU S35      eU $ )z$Get instance of matplotlib colormap.z	Colormap z is not recognized)r   strmpl	colormaps
ValueError)r   r0   s     r   r-   r-      sB    (C  ==*y.@ABBOr   c                    [        U 5      S:X  a  [        SU  35      e[        U 5      (       a  [        [        U 5      n U /$ [        [
        [           U 5      n [        [        U 5      5      $ )z!Get colors from user input color.r   zInvalid color argument: )r%   r5   _is_single_colorr   Colorr   r   !_gen_list_of_colors_from_iterabler   s    r   r!   r!      sb     5zQ3E7;<<UE"wE"E*E1%899r   c                r    [        U [        5      (       a  [        U 5      (       a  g[        U 5      (       a  gg)a  Check if `color` is a single color, not a sequence of colors.

Single color is of these kinds:
    - Named color "red", "C0", "firebrick"
    - Alias "g"
    - Sequence of floats, such as (0.1, 0.2, 0.3) or (0.1, 0.2, 0.3, 0.4).

See Also
--------
_is_single_string_color
TF)r   r2   _is_single_string_color_is_floats_colorr:   s    r   r7   r7      s0     %"9%"@"@r   c              #  b   #    U  H%  n[        U5      (       a  Uv   M  [        SU 35      e   g7f)zK
Yield colors from string of several letters or from collection of colors.
zInvalid color N)r7   r5   )r   xs     r   r9   r9      s3      AG~aS122	 s   -/c                    [        [        U 5      =(       a<    [        U 5      S:H  =(       d    [        U 5      S:H  =(       a    [        S U  5       5      5      $ )zACheck if color comprises a sequence of floats representing color.      c              3  N   #    U  H  n[        U[        [        45      v   M     g 7f)N)r   intfloat).0r?   s     r   	<genexpr>#_is_floats_color.<locals>.<genexpr>   s     ;U
1sEl++Us   #%)boolr
   r%   allr:   s    r   r=   r=      sG    U 	<Z1_/E
a	<;U;; r   c                \    U S:X  a  [        U5      $ U S:X  a  [        U5      $ [        S5      e)z&Get colors from user input color type.defaultrandomz/color_type must be either 'default' or 'random')_get_default_colors_get_random_colorsr5   )r   r   s     r   r"   r"      s4    Y":..	x	!*--JKKr   c                d    SSK Jn  UR                  S    Vs/ s H  o"S   PM	     nnUSU  $ s  snf )z=Get `num_colors` of default colors from matplotlib rc params.r   Nzaxes.prop_cycler   )matplotlib.pyplotpyplotrcParams)r   pltcr   s       r   rN   rN      s:    #"%,,/@"AB"AQj"AFB!J Cs   -c                V    [        U 5       Vs/ s H  n[        U5      PM     sn$ s  snf )z"Get `num_colors` of random colors.)range_random_color)r   r,   s     r   rO   rO      s&    */
*;<*;3M#*;<<<s   &c                l    [         R                  " U 5      nUR                  S5      R                  5       $ )z4Get a random color represented as a list of length 3rA   )comrandom_staterandtolist)columnrss     r   rX   rX      s+     
		&	!B771:r   c                    [         R                  R                  5       n UR                  U 5        g! [         a     gf = f)a?  Check if `color` is a single string color.

Examples of single string colors:
    - 'r'
    - 'g'
    - 'red'
    - 'green'
    - 'C3'
    - 'firebrick'

Parameters
----------
color : Color
    Color string or sequence of floats.

Returns
-------
bool
    True if `color` looks like a valid color.
    False otherwise.
TF)
matplotlibr   ColorConverterto_rgbar5   )r   convs     r   r<   r<      sD    , ++-D 	U   s   2 
??)NrL   N)r   rD   r   zColormap | Noner   r2   r   z3dict[str, Color] | Color | Collection[Color] | None)
r   z Color | Collection[Color] | Noner   zstr | Colormap | Noner   r2   r   rD   returnlist[Color])r   rf   r   rD   re   Iterator[Color])r   str | Colormapr   rD   re   rf   )r   rh   re   r   )r   Color | Collection[Color]re   rf   )r   ri   re   rI   )r   zCollection[Color]re   rg   )r   r2   r   rD   re   rf   )r   rD   re   rf   )r^   rD   re   zlist[float])r   r8   re   rI   ))
__future__r   collections.abcr   r   r&   typingr   r   r   ra   r3   matplotlib.colorsnumpyr.   pandas._typingr   r8   pandas.util._exceptionsr	   pandas.core.dtypes.commonr
   pandas.core.commoncorecommonrZ   r   r   r   r   r   r-   r!   r7   r9   r=   r"   rN   rO   rX   r<    r   r   <module>rv      s   "      3 4 2    *
 !%AE	0>0>0> 0> ?	0>f1N+1N $1N 	1N
 1N 1NhEDDD D:$::,3L =
r   