/ lib / pandas / plotting / _matplotlib / style.pyc
style.pyc
  1  o

  2  d��c�!�@sNddlmZddlZddlmZmZmZmZmZm	Z	ddl
  3  Z
  4  ddlZddl
mZddlZddlZddlmZddlmZddlmmZddlmZerSddlmZeeeefZ			d;d<dd�Z d=dd�Z!d>dd�Z"d?dd�Z#d@d!d"�Z$dAd$d%�Z%dBd'd(�Z&dCd*d+�Z'dBd,d-�Z(dDd.d/�Z)dEd0d1�Z*dEd2d3�Z+dFd6d7�Z,dGd9d:�Z-dS)H�)�annotationsN)�
TYPE_CHECKING�
  5  Collection�Iterator�Sequence�Union�cast)�find_stack_level)�is_list_like)�mpl_ge_3_6_0)�Colormap�default�
  6  num_colors�int�colormap�Colormap | None�
  7  color_type�str�color�3dict[str, Color] | Color | Collection[Color] | NonecCs.t|t�r|St||||d�}tt||d��S)a�
  8      Get standard colors based on `colormap`, `color_type` or `color` inputs.
  9  
 10      Parameters
 11      ----------
 12      num_colors : int
 13          Minimum number of colors to be returned.
 14          Ignored if `color` is a dictionary.
 15      colormap : :py:class:`matplotlib.colors.Colormap`, optional
 16          Matplotlib colormap.
 17          When provided, the resulting colors will be derived from the colormap.
 18      color_type : {"default", "random"}, optional
 19          Type of colors to derive. Used if provided `color` and `colormap` are None.
 20          Ignored if either `color` or `colormap` are not None.
 21      color : dict or str or sequence, optional
 22          Color(s) to be used for deriving sequence of colors.
 23          Can be either be a dictionary, or a single color (single color string,
 24          or sequence of floats representing a single color),
 25          or a sequence of colors.
 26  
 27      Returns
 28      -------
 29      dict or list
 30          Standard colors. Can either be a mapping if `color` was a dictionary,
 31          or a list of colors with a length of `num_colors` or more.
 32  
 33      Warns
 34      -----
 35      UserWarning
 36          If both `colormap` and `color` are provided.
 37          Parameter `color` will override.
 38      �rrrr�r)�
 39  isinstance�dict�_derive_colors�list�
_cycle_colors)rrrr�colors�r��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\plotting\_matplotlib\style.py�get_standard_colors"s
 40  &�r � Color | Collection[Color] | None�str | Colormap | None�return�list[Color]cCsP|dur|durt||d�S|dur"|durtjdt�d�t|�St||d�S)aa
 41      Derive colors from either `colormap`, `color_type` or `color` inputs.
 42  
 43      Get a list of colors either from `colormap`, or from `color`,
 44      or from `color_type` (if both `colormap` and `color` are None).
 45  
 46      Parameters
 47      ----------
 48      color : str or sequence, optional
 49          Color(s) to be used for deriving sequence of colors.
 50          Can be either be a single color (single color string, or sequence of floats
 51          representing a single color), or a sequence of colors.
 52      colormap : :py:class:`matplotlib.colors.Colormap`, optional
 53          Matplotlib colormap.
 54          When provided, the resulting colors will be derived from the colormap.
 55      color_type : {"default", "random"}, optional
 56          Type of colors to derive. Used if provided `color` and `colormap` are None.
 57          Ignored if either `color` or `colormap`` are not None.
 58      num_colors : int
 59          Number of colors to be extracted.
 60  
 61      Returns
 62      -------
 63      list
 64          List of colors extracted.
 65  
 66      Warns
 67      -----
 68      UserWarning
 69          If both `colormap` and `color` are provided.
 70          Parameter `color` will override.
 71      NrzC'color' and 'colormap' cannot be used simultaneously. Using 'color')�
 72  stacklevel)�_get_colors_from_colormap�warnings�warnr	�_get_colors_from_color�_get_colors_from_color_typerrrrrUs'�rr�Iterator[Color]ccs,�t|t|��}t�t�|�|�EdHdS)z�Cycle colors until achieving max of `num_colors` or length of `colors`.
 73  
 74      Extra colors will be ignored by matplotlib if there are more colors
 75      than needed and nothing needs to be done here.
 76      N)�max�len�	itertools�islice�cycle)rrZ
 77  max_colorsrrrr�s�r�str | Colormapcs&t|���fdd�tjdd|d�D�S)zGet colors from colormap.csg|]}�|��qSrr��.0�num��cmaprr�
 78  <listcomp>��z-_get_colors_from_colormap.<locals>.<listcomp>r�)r4)�_get_cmap_instance�np�linspace)rrrr5rr&�sr&rcCsFt|t�r!|}t�rtj|}nt�|�}|dur!td|�d���|S)z$Get instance of matplotlib colormap.Nz	Colormap z is not recognized)rrr�mpl�	colormaps�cm�get_cmap�
 79  ValueError)rr6rrrr:�s
 80  
 81  r:�Color | Collection[Color]cCsLt|�dkr
td|����t|�rtt|�}|gSttt|�}tt|��S)z!Get colors from user input color.rzInvalid color argument: )r-rA�_is_single_colorr�Colorrr�!_gen_list_of_colors_from_iterable�rrrrr)�s
 82  r)�boolcCs&t|t�rt|�rdSt|�rdSdS)a0Check if `color` is a single color, not a sequence of colors.
 83  
 84      Single color is of these kinds:
 85          - Named color "red", "C0", "firebrick"
 86          - Alias "g"
 87          - Sequence of floats, such as (0.1, 0.2, 0.3) or (0.1, 0.2, 0.3, 0.4).
 88  
 89      See Also
 90      --------
 91      _is_single_string_color
 92      TF)rr�_is_single_string_color�_is_floats_colorrFrrrrC�s
 93  rC�Collection[Color]ccs,�|D]}t|�r
|Vqtd|����dS)zS
 94      Yield colors from string of several letters or from collection of colors.
 95      zInvalid color N)rCrA)r�xrrrrE�s��rEcCs6tt|�ot|�dkpt|�dkotdd�|D���S)zACheck if color comprises a sequence of floats representing color.��css�|]
 96  }t|ttf�VqdS)N)rr�float)r3rKrrr�	<genexpr>�s�z#_is_floats_color.<locals>.<genexpr>)rGr
 97  r-�allrFrrrrI�s��rIcCs(|dkrt|�S|dkrt|�Std��)z&Get colors from user input color type.r
�randomz/color_type must be either 'default' or 'random')�_get_default_colors�_get_random_colorsrA)rrrrrr*�s
 98  r*cCs,ddlm}dd�|jdD�}|d|�S)z=Get `num_colors` of default colors from matplotlib rc params.rNcSsg|]}|d�qSrFr)r3�crrrr7�r8z'_get_default_colors.<locals>.<listcomp>zaxes.prop_cycle)�matplotlib.pyplot�pyplot�rcParams)r�pltrrrrrR�srRcCsdd�t|�D�S)z"Get `num_colors` of random colors.cSsg|]}t|��qSr)�
_random_colorr2rrrr7�r8z&_get_random_colors.<locals>.<listcomp>)�rangerrrrrS�srS�column�list[float]cCst�|�}|�d���S)z4Get a random color represented as a list of length 3rL)�com�random_state�rand�tolist)r[�rsrrrrY�s
 99  rYrDcCs0tj��}z|�|�WdStyYdSw)a�Check if `color` is a single string color.
100  
101      Examples of single string colors:
102          - 'r'
103          - 'g'
104          - 'red'
105          - 'green'
106          - 'C3'
107          - 'firebrick'
108  
109      Parameters
110      ----------
111      color : Color
112          Color string or sequence of floats.
113  
114      Returns
115      -------
116      bool
117          True if `color` looks like a valid color.
118          False otherwise.
119      FT)�
120  matplotlibrZColorConverter�to_rgbarA)r�convrrrrHs
121  ��rH)Nr
N)rrrrrrrr)
122  rr!rr"rrrrr#r$)rr$rrr#r+)rr1rrr#r$)rr1r#r)rrBr#r$)rrBr#rG)rrJr#r+)rrrrr#r$)rrr#r$)r[rr#r\)rrDr#rG).�
123  __future__rr.�typingrrrrrrr'rbr=�
matplotlib.cmr?�matplotlib.colors�numpyr;�pandas.util._exceptionsr	�pandas.core.dtypes.commonr
124  �pandas.core.common�core�commonr]�"pandas.plotting._matplotlib.compatrrrrNrDr rrr&r:r)rCrErIr*rRrSrYrHrrrr�<module>s@ �
125  3
126  4
127  
128  
129  	
130  
131  
132  
133  
134  	
135  
136  
137  
138