L il4ddlZddlmZddlZddlZddlmZddl m Z m Z ddl m Z mZddlmZgdZegd gd gd gd gd gdgdgdgdgdgdgd Zddddddddddddd Zej+Zej/ej1Dcic]\}}|e|c}}eej7ZGddeZdZd-dZd.d Z d/d!Z!d0d"Z"d#Z#d1d$Z$d1d%Z% d2d&Z&d3d'Z'd(Z(d)Z) d4d*Z*d+Z+d5d,Z,ycc}}w)6N)cycle)husl) desaturateget_color_cycle)xkcd_rgbcrayons) get_colormap) color_palette hls_palette husl_palette mpl_palette dark_palette light_palettediverging_palette blend_palette xkcd_palettecrayon_palettecubehelix_paletteset_color_codes) #4C72B0z#DD8452#55A868#C44E52#8172B3z#937860z#DA8BC3z#8C8C8C#CCB974#64B5CD)rrrrrr) #4878D0z#EE854A#6ACC64#D65F5F#956CB4z#8C613Cz#DC7EC0z#797979#D5BB67#82C6E2)rrrr r!r") #A1C9F4z#FFB482#8DE5A1#FF9F9B#D0BBFFz#DEBB9Bz#FAB0E4z#CFCFCF#FFFEA3#B9F2F0)r#r$r%r&r'r() #023EFFz#FF7C00#1AC938#E8000B#8B2BE2z#9F4800z#F14CC1z#A3A3A3#FFC400#00D7FF)r)r*r+r,r-r.) #001C7Fz#B1400D#12711C#8C0800#591E71z#592F0Dz#A23582z#3C3C3C#B8850A#006374)r/r0r1r2r3r4) #0173B2z#DE8F05#029E73#D55E00#CC78BCz#CA9161z#FBAFE4z#949494#ECE133#56B4E9)r5r6r7r8r9r:) deepdeep6mutedmuted6pastelpastel6brightbright6darkdark6 colorblind colorblind6   ) tab10tab20tab20btab20cSet1Set2Set3AccentPairedPastel1Pastel2Dark2c(eZdZdZdZdZdZdZy) _ColorPalettez?Set the color palette in a with statement, otherwise be a list.c@ddlm}t|_|||S)zOpen the context.r set_palette)rcmodr\r _orig_palette)selfr\s V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/seaborn/palettes.py __enter__z_ColorPalette.__enter__?s&*_D c4ddlm}||jy)zClose the context.rr[N)r]r\r^)r_argsr\s r`__exit__z_ColorPalette.__exit__Fs&D&&'rbcz|Dcgc]!}tjj|#}}t|Scc}w)zz z)len enumeraterl)r_snhtmlics r` _repr_html_z_ColorPalette._repr_html_Ps  Iq1ugZs"5dkkm, DAq AE7/!JqcPQsS<< D   rbN)__name__ __module__ __qualname____doc__rarerlrwrbr`rYrY=sI( " rbrYcd}d}|tjj_|tjj_y)zASimplify the rich display of matplotlib color maps in a notebook.cddl}ddlm}ddl}d}|j|j dd|d|ddf}||d}|j }|j|j|d |jS) z.Generate a PNG representation of the Colormap.rN)Image)i2rT)bytespng)format) ioPILrnumpytilelinspaceBytesIO fromarraysavegetvalue)r_rrnp IMAGE_SIZEXpixels png_bytess r` _repr_png_z+_patch_colormap_display.._repr_png_`s BGGKBKK1jm4z!}a6H Iat$JJL  $$Yu$=!!##rbcddl}|j}|j|jd}d|jzdzdz|jzdzdz|zd zS) z0Generate an HTML representation of the Colormap.rNasciiz z color map' - 'light:', 'dark:', 'blend:,', - A sequence of colors in any format matplotlib accepts Calling this function with ``palette=None`` will return the current matplotlib color cycle. This function can also be used in a ``with`` statement to temporarily set the color cycle for a plot or set of plots. See the :ref:`tutorial ` for more information. Parameters ---------- palette : None, string, or sequence, optional Name of palette or None to return current palette. If a sequence, input colors are used but possibly cycled and desaturated. n_colors : int, optional Number of colors in the palette. If ``None``, the default will depend on how ``palette`` is specified. Named palettes default to 6 colors, but grabbing the current palette or passing in a list of colors will not change the number of colors unless this is specified. Asking for more colors than exist in the palette will cause it to cycle. Ignored when ``as_cmap`` is True. desat : float, optional Proportion to desaturate each color by. as_cmap : bool If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- set_palette : Set the default color cycle for all plots. set_color_codes : Reassign color codes like ``"b"``, ``"g"``, etc. to colors from one of the seaborn palettes. Examples -------- .. include:: ../docstrings/color_palette.rst Nhlsas_cmaprjetzNo.ch:rzlight::_r)reverserzdark:zblend:,z is not a valid palette namez!Could not generate a palette for )rrp isinstancestrQUAL_PALETTE_SIZESgetSEABORN_PALETTESr r lower ValueError startswith_parse_cubehelix_argsrsplitendswithrrrrKeyErrorrrrangenextmaprgrhcolorConverterto_rgbrY) paletten_colorsdesatrrdkwargs_colorrrhrv pal_cycles r`r r zsh!#  7|H  %  7|H  )--gq9H & &&w/G  !(G9JI6JcF|rd}tjddt|dzdd}||z }|dz}||jtz}|Dcgc]}t j |||}}|r t jj|dSt|Scc}w)aC Return hues with constant lightness and saturation in the HLS system. The hues are evenly sampled along a circular path. The resulting palette will be appropriate for categorical or cyclical data. The `h`, `l`, and `s` values should be between 0 and 1. .. note:: While the separation of the resulting colors will be mathematically constant, the HLS system does not construct a perceptually-uniform space, so their apparent intensity will vary. Parameters ---------- n_colors : int Number of colors in the palette. h : float The value of the first hue. l : float The lightness value. s : float The saturation intensity. as_cmap : bool If True, return a matplotlib colormap object. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- husl_palette : Make a palette using evenly spaced hues in the HUSL system. Examples -------- .. include:: ../docstrings/hls_palette.rst rrNr) rrintastypecolorsys hls_to_rgbrgrhListedColormaprY)rhlrrrhuesh_irs r`r r sR ;;q!S]Q. / 4DAIDAIDDKK D9=>#x""31->G>zz((%88W%% ?sBc&|rd}tjddt|dzdd}||z }|dz}|dz}|dz}|dz}|Dcgc]}t|||fd }}|r tj j |d St|Scc}w) a Return hues with constant lightness and saturation in the HUSL system. The hues are evenly sampled along a circular path. The resulting palette will be appropriate for categorical or cyclical data. The `h`, `l`, and `s` values should be between 0 and 1. This function is similar to :func:`hls_palette`, but it uses a nonlinear color space that is more perceptually uniform. Parameters ---------- n_colors : int Number of colors in the palette. h : float The value of the first hue. l : float The lightness value. s : float The saturation intensity. as_cmap : bool If True, return a matplotlib colormap object. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- hls_palette : Make a palette using evenly spaced hues in the HSL system. Examples -------- .. include:: ../docstrings/husl_palette.rst rrrNrigcrinputhsl)rrr _color_to_rgbrgrhrrY)rrrrrrrrrs r`r r 8sN ;;q!S]Q. / 4DAIDAIDCKDGAGACGHC}c1a[7HGHzz((%88W%% IsBc |jdrI|dd}|jdrd}|dd}nd}t|ddgz}|r|ddd }t||d }n t|}|tvr"t j d d t|d|}n&t j d d t|dzd d }ttt||dddd f}|r|St|S)a3 Return a palette or colormap from the matplotlib registry. For continuous palettes, evenly-spaced discrete samples are chosen while excluding the minimum and maximum value in the colormap to provide better contrast at the extremes. For qualitative palettes (e.g. those from colorbrewer), exact values are indexed (rather than interpolated), but fewer than `n_colors` can be returned if the palette does not define that many. Parameters ---------- name : string Name of the palette. This should be a named matplotlib colormap. n_colors : int Number of discrete colors in the palette. Returns ------- list of RGB tuples or :class:`matplotlib.colors.ListedColormap` Examples -------- .. include:: ../docstrings/mpl_palette.rst _dNrrTFz#333333rrrr) rr rr MPL_QUAL_PALSrrrlistrtuplerY) rrrsub_namerpalcmapbinsrs r`rrns8 }}T9   T "G}HGHa(I;6 dd)CS(D9D! }{{1at!45ix@{{1aX!23Ab93ud4jBQB/01G W%%rbc|dk(rtj|}nF|dk(r3tj|}t t j |dd}n|dk(r t|}tjj|S)z+Add some more flexibility to color choices.rrrrxkcd) rrr husl_to_rgbrrcliprrgrhr)rrs r`rrsl ~##U+ &  %(bggeQ*+ & ::  U ##rbct||}tj|\}}}d|zd} } t|| | fd} |r|| gn| |g} t| ||S)aMake a sequential palette that blends from dark to ``color``. This kind of palette is good for data that range between relatively uninteresting low values and interesting high values. The ``color`` parameter can be specified in a number of ways, including all options for defining a color in matplotlib and several additional color spaces that are handled by seaborn. You can also use the database of named colors from the XKCD color survey. If you are using the IPython notebook, you can also choose this palette interactively with the :func:`choose_dark_palette` function. Parameters ---------- color : base color for high values hex, rgb-tuple, or html color name n_colors : int, optional number of colors in the palette reverse : bool, optional if True, reverse the direction of the blend as_cmap : bool, optional If True, return a :class:`matplotlib.colors.ListedColormap`. input : {'rgb', 'hls', 'husl', xkcd'} Color space to interpret the input color. The first three options apply to tuple inputs and the latter applies to string inputs. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- light_palette : Create a sequential palette with bright low values. diverging_palette : Create a diverging palette with two colors. Examples -------- .. include:: ../docstrings/dark_palette.rst 333333?rrrr rgb_to_huslr rrrrrrjhuesatrgray_sgray_lgrayrhs r`rrsgV u %C""C(KCa3YFF #vv.f =D#c4[$F 7 33rbct||}tj|\}}}d|zd} } t|| | fd} |r|| gn| |g} t| ||S)axMake a sequential palette that blends from light to ``color``. The ``color`` parameter can be specified in a number of ways, including all options for defining a color in matplotlib and several additional color spaces that are handled by seaborn. You can also use the database of named colors from the XKCD color survey. If you are using a Jupyter notebook, you can also choose this palette interactively with the :func:`choose_light_palette` function. Parameters ---------- color : base color for high values hex code, html color name, or tuple in `input` space. n_colors : int, optional number of colors in the palette reverse : bool, optional if True, reverse the direction of the blend as_cmap : bool, optional If True, return a :class:`matplotlib.colors.ListedColormap`. input : {'rgb', 'hls', 'husl', xkcd'} Color space to interpret the input color. The first three options apply to tuple inputs and the latter applies to string inputs. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- dark_palette : Create a sequential palette with dark low values. diverging_palette : Create a diverging palette with two colors. Examples -------- .. include:: ../docstrings/light_palette.rst r_rrrrs r`rrsgP u %C""C(KCa3YFF #vv.f =D#c4[$F 7 33rbcttt|}td|dzz } ||||f| dd} ||||f| d} tdgd g |} | |z} t t j | | | g|| }|S) aMake a diverging palette between two HUSL colors. If you are using the IPython notebook, you can also choose this palette interactively with the :func:`choose_diverging_palette` function. Parameters ---------- h_neg, h_pos : float in [0, 359] Anchor hues for negative and positive extents of the map. s : float in [0, 100], optional Anchor saturation for both extents of the map. l : float in [0, 100], optional Anchor lightness for both extents of the map. sep : int, optional Size of the intermediate region. n : int, optional Number of colors in the palette (if not returning a cmap) center : {"light", "dark"}, optional Whether the center of the palette is light or dark as_cmap : bool, optional If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- dark_palette : Create a sequential palette with dark values. light_palette : Create a sequential palette with light values. Examples -------- .. include: ../docstrings/diverging_palette.rst )rClightrTr)rrr)ffffff?rr)/$?rr)rrCr)dictrrrrr concatenate)h_negh_posrrrseprscenterrpalfuncn_halfnegposmidpointmidrs r`rrsN M:6BG q! "F 5!Q-V DC 5!Q-v 6C?+3E2FGOH S.C S#7G LC Jrbc .|Dcgc]}t||}}d}tjjj ||}|sH|t j ddt|ddddf}ttt|}|Scc}w)aAMake a palette that blends between a list of colors. Parameters ---------- colors : sequence of colors in various formats interpreted by `input` hex code, html color name, or tuple in `input` space. n_colors : int, optional Number of colors in the palette. as_cmap : bool, optional If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` Examples -------- .. include: ../docstrings/blend_palette.rst blendrrNr) rrgrhLinearSegmentedColormap from_listrrrrYrr)rhrrrrrr rgb_arrays r`rrEs,8> >emE5) >F > D ** , , 6 6tV DC  Aq#h-89!RaR%@ Cy12 J ?sBcb|Dcgc] }t| }}t|t|Scc}w)aMake a palette with color names from the xkcd color survey. See xkcd for the full list of colors: https://xkcd.com/color/rgb/ This is just a simple wrapper around the `seaborn.xkcd_rgb` dictionary. Parameters ---------- colors : list of strings List of keys in the `seaborn.xkcd_rgb` dictionary. Returns ------- palette A list of colors as RGB tuples. See Also -------- crayon_palette : Make a palette with Crayola crayon colors. )rr rprhrrs r`rrds1,+11$x~1G1 #g, //2,cb|Dcgc] }t| }}t|t|Scc}w)aMake a palette with color names from Crayola crayons. Colors are taken from here: https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors This is just a simple wrapper around the `seaborn.crayons` dictionary. Parameters ---------- colors : list of strings List of keys in the `seaborn.crayons` dictionary. Returns ------- palette A list of colors as RGB tuples. See Also -------- xkcd_palette : Make a palette with named colors from the XKCD color survey. )r r rprs r`rr~s1.*00wt}0G0 #g, //1rc fd} | dd| dd| ddd} tjjd | } tj||t |} | | d d d d fj } |r| d d d } |rKtj||d }|r|d d d }| |}tjj|d} | St| S)aQMake a sequential palette from the cubehelix system. This produces a colormap with linearly-decreasing (or increasing) brightness. That means that information will be preserved if printed to black and white or viewed by someone who is colorblind. "cubehelix" is also available as a matplotlib-based palette, but this function gives the user more control over the look of the palette and has a different set of defaults. In addition to using this function, it is also possible to generate a cubehelix palette generally in seaborn using a string starting with `ch:` and containing other parameters (e.g. `"ch:s=.25,r=-.5"`). Parameters ---------- n_colors : int Number of colors in the palette. start : float, 0 <= start <= 3 The hue value at the start of the helix. rot : float Rotations around the hue wheel over the range of the palette. gamma : float 0 <= gamma Nonlinearity to emphasize dark (gamma < 1) or light (gamma > 1) colors. hue : float, 0 <= hue <= 1 Saturation of the colors. dark : float 0 <= dark <= 1 Intensity of the darkest color in the palette. light : float 0 <= light <= 1 Intensity of the lightest color in the palette. reverse : bool If True, the palette will go from dark to light. as_cmap : bool If True, return a :class:`matplotlib.colors.ListedColormap`. Returns ------- palette list of RGB tuples or :class:`matplotlib.colors.ListedColormap` See Also -------- choose_cubehelix_palette : Launch an interactive widget to select cubehelix palette parameters. dark_palette : Create a sequential palette with dark low values. light_palette : Create a sequential palette with bright low values. References ---------- Green, D. A. (2011). "A colour scheme for the display of astronomical intensity images". Bulletin of the Astromical Society of India, Vol. 39, p. 289-295. Examples -------- .. include:: ../docstrings/cubehelix_palette.rst c fd}|S)Nc|z}|zd|z zdz }dtjz dz |zzz}||tj|ztj|zzzzS)Nrrr)rpicossin) xxgaphigammarp0p1rotstarts r`rz.get_color_function..colorsseB bAF#a'Abee)uqy3723CR"&&+-RVVC[0@@AA Arbr|)rrrrrrrs`` r`get_color_functionz-cubehelix_palette..get_color_functions B B rbgKÿg9?gۅ:ҿgRQg)?)redgreenblue cubehelixNrrrseaborn_cubehelix) rgrhrrrrtolistrrY)rrrrrrrCrrrcdictrrrx_256pal_256s ```` r`rrsv""(G4#Hh7"7C0 E :: - -k5 AD E4X/A q'!RaR%.   !C$B$i E4- $B$KEu+zz((2EF S!!rbc v|jdr|dd}|jdrd}|dd}nd}|sgd|ifS|jd }|Dcgc]!}d |vst|j d #}}|Dcgc]}d |vs|jd }}|Dcic]/\}}|j d t|j d 1}}}t d d dddd}|j Dcic]\}}|j|||}}}|rd|d<||fScc}wcc}wcc}}wcc}}w)z3Turn stringified cubehelix params into args/kwargs.rrNrTrFrr= rrrrrrC)rrrgrrd)rrrfloatstripritemsr) argstrrall_argsrrdrkv kwarg_maps r`rrsG t Iw'''||C H)1 BAS\E!''#,  BD B$, 9qqaggcl 9F 9F)rF)rFFrj)KrrrrF)rFrj) rrg?r3g?g333333?rFF)r;)-r itertoolsrrr matplotlibrgexternalrutilsrrrhrr _compatr __all__rrrcopyrupdater+rprkeys QUAL_PALETTESrYrr r r rrrrrrrrrrr)r.r/s00r`rJsh.%! 3  A , B - C . C . A ,G2/:"b q"2Q  #'')1A1G1G1IJA1c!f9JK',,./ DB28EP3&l3&l3&l $04f-4`:;.3.b>0406CFBG`"F F*5MKsD