L iS"dZddlmZddlmZddlZddlZddlZddlZ ddl Z ddl Z ddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZmZmZdd l m!Z!dd l"m#Z#m$Z$dd l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3m4Z4gdZ5e6ddddddZ7e3jpe4de3e$e3e7e3jrejte3jrejte3jrejtZ;GddeZ< dBdddddddddd d!d!d"d#d!dd dddddd dddddddd!dd$ d%Z=d&j}e;e4d'e4d()e=_ dBdddddddddd"d!d d d*dd!dd+d,d-d.dd!d dddd/d0Z?d1j}e;e4d'e4d()e?_ dBddddd2d ddddd!dd3 d4Z@d5j}e;e4d'e4d()e@_ dBdddd6d!dddd!dd7 d8ZAd9j}e;e4d':eA_ dBddddddd;d ddd!ddddddddZBd?j}e;e4d'e4d()eB_d@ZC dCdAZDy)Dz1Plotting functions for visualizing distributions.)Number)partialN)normalize_kwargs)to_rgba)LineCollection) VectorPlotter)ECDF HistogramKDE)Hist) FacetGrid _facet_docs) remove_na_get_transform_functions _kde_support_check_argument_assign_default_kwargs_default_color) color_palette)husl) gaussian_kde)DocstringComponents _core_docs)displothistplotkdeplotecdfplotrugplotdistplotz multiple : {{"layer", "stack", "fill"}} Method for drawing multiple elements when semantic mapping creates subsets. Only relevant with univariate data. a^ log_scale : bool or number, or pair of bools or numbers Set axis scale(s) to log. A single value sets the data axis for any numeric axes in the plot. A pair of values sets each axis independently. Numeric values are interpreted as the desired base (default 10). When `None` or `False`, seaborn defers to the existing Axes scale. zM legend : bool If False, suppress the legend for semantic variables. z cbar : bool If True, add a colorbar to annotate the color mapping in a bivariate plot. Note: Does not currently support plots with a ``hue`` variable well. zU cbar_ax : :class:`matplotlib.axes.Axes` Pre-existing axes for the colorbar. zd cbar_kws : dict Additional parameters passed to :meth:`matplotlib.figure.Figure.colorbar`. )multiple log_scalelegendcbarcbar_axcbar_kwsparams)corefacetsdistkdehistecdfceZdZdddZddiZdiffd ZedZedZed Z d Z d Z d Z d Z dZdZ ddZdZdZdZdZdZdZdZxZS)_DistributionPlotterz@valuesz@columns)xhuer0Nc(t|||y)Ndata variables)super__init__)selfr4r5 __class__s [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/seaborn/distributions.pyr7z_DistributionPlotter.__init__hs di8cHtddht|jz S)z$Return True if only x or y are used.r0yboolsetr5r8s r: univariatez_DistributionPlotter.univariateps!S#JT^^!4455r;c|js tdddhj|jj S)z3Return the variable with data for univariate plots.zThis is not a univariate plotr0r=)rBAttributeError intersectionr5poprAs r: data_variablez"_DistributionPlotter.data_variableys9 !@A ASz&&t~~6::<rAs r: has_xy_dataz _DistributionPlotter.has_xy_datas!S#JT^^!4455r;c &g} g} |jjD]g} |j| } |j||||| |} d| vr| jdd| j |di| | j | it |t jjr$|j| | fd|jdi|ytt| | }|j|f|jd|jdd|y)zDAdd artists that reflect semantic mappings and put then in a legend. facecolorcolorNtitler1)rM label_order)_hue_maplevels _artist_kwsrFappend isinstancemplaxesAxesr#r5dictzip add_legend var_levels)r8ax_objartistfillelementr!alpha artist_kws legend_kwshandleslabelslevelrLkws legend_datas r: _add_legendz _DistributionPlotter._add_legends  ]])) !EMM%(E""D'8UECc!& NN6=C= ) MM%  ! fchhmm , FMM'6 U1F U* Us6734K F   nnU+ OOE2   r;c|j}|rt|tjj}|j dt |||dk(rd|d<|dvs|dk(r%|j dtjd|S|j dt |d|S|dk(rd|d<t |||d<|St |||d<|S) z&  &G ,,60A{CLL9J,KL {GE1,=>   %C &ue4C  #5%0CL r;c>tj|}tj|}tj|ddd}tj||j z }tj |d|z }tj||d}|S)z:Return data levels corresponding to quantile cuts of mass.Nrclip)mode)npasarrayravelsortcumsumsum searchsortedtake) r8r4quantileisopropvalues sorted_valuesnormalized_valuesidxrQs r:_quantile_to_levelz'_DistributionPlotter._quantile_to_levelsy**X&$"- IIm4vzz|Coo/W=&9 r;ct|\}}}}tj|||\}}}tjddt ddd}tj d} || dddf<|tj|z| dddf<tjdd d| ddd f<tj| D cgc]} tj| c} dd} tjj| dddScc} w) z0Return a sequential colormap given a color seed.rurgffffffr@N)rr#P) rr rgb_to_huslrxlinspaceintzeroscosrv husl_to_rgbrUcolorsListedColormap) r8rLrgb_hsxxramphslrs r:_cmap_from_colorz%_DistributionPlotter._cmap_from_colorsU^ 1a""1a+1a [[QJ 0# 6xx!QT ^QT [[R-QT DAS$**C0A1aHzz(("66Bs=Dc|jr|j|jdk(}|S|jddk(}|jddk(}||f}|S)zHFind default values for discrete hist estimation based on variable type. categoricalr0r=)rB var_typesrG)r8discrete discrete_x discrete_ys r:_default_discretez&_DistributionPlotter._default_discretes` ??~~d&8&89]JH , =J, =J!:-Hr;c|jDcic]\}}|tj|}}}d|jvr||fS|dvrGt j |j dddddf}i}ttt|jD]O\}}|jdd|jddf} |j| g|| j|Q|j}|jD]} |j| } || j!d} || j#d|| <|d k(r|| j%| d || <|| j'd d j)d || <|d k(r|j*d} t-| }|j/|j0\}}|D]}t|d}||j3d}| j5|}||d}||d|dz}||z |z }||||zz}|||d z|zz}||z |d<||d<|j7ddgd||<||fScc}}w)z?Modify the density data structure to handle multiple densities.r1rlNrucolrowcolumnsaxisr^indexrrdodgeheightsnameedgeswidths)itemsrx zeros_liker5pd DataFrameiloc enumeratemaprXrgetrrrSrorr}r|divshiftfillnar[len_get_scale_transformsrG reset_indexr set_index)r8curvesr!kv baselines column_groupsikeyd facet_keycol_idxscols norm_constant hue_levelsnf_fwdf_invkeyrer, level_idxarwnew_minnew_maxs r:_resolve_multiplez&_DistributionPlotter._resolve_multiples6<\\^DTQQ a((D D  &9$ $ ( ( \\&)..q$B$w7FM$Sv~~%>? 34 HHUD1488E43HH ((B7i(//2 3  I)002 J~~h/ &t 0 0i 0 @  &d|22 2Bt v%#)$<#3#3M#3#PF4L#),"4"4QQ"4"?"F"Fq"I $ J w /JJA55d6H6HILE5 MS %(c{..I.>&,,U3 $w-($w-$x.89UaKIM 12Y]a$7 78!(7!2X 'W "nngx-@A)Ls  M y  {Es I:ctdi|}t|jddhz r1|r1|jj }|j ||nd}|j j }|rd|vr|dj} n t|} i} |jddD]\} } | |} d|jvr| d}|j}n d}t| }tj| j}t| dkxstj|d } |s || | \}}|r!d }|rt#j$|t&d |j)|j*\}}|}|r|| z z}t-| j/}t1j2|| |<| S#tjj $rd}YwxYw)Nr0r=Fweightsr1Tfrom_comp_datarrrzfDataset has 0 variance; skipping density estimate. Pass `warn_singular=False` to disable this warning. stacklevel)rrO)r r@r5 comp_datadropnadefine_support plot_datar}r iter_datarx nan_to_numvarmathiscloselinalg LinAlgErrorwarningswarn UserWarningrrGtuplerrSeries)r8rG common_norm common_grid estimate_kws warn_singular estimatorall_observationsall_data whole_weight densitiessub_varssub_data observationsr part_weightvariancesingulardensitysupportmsgrrrs r:_compute_univariate_densityz0_DistributionPlotter._compute_univariate_density*s',' t~~ #s +#'>>#8#8#: (()9-)HIK>>((* 90#I.224Lx=L "&..t."L+ ? Hh$M2LDNN*"9-%kkm !(m }}\%5%5%78H<(1,I Xq0IH (1w'O$GWJ!MM#{qA11$2D2DEHAuGnG;55()CYYwg>IcNW+ ?Z199((  s4GG0/G0c |in|j}| in| j} | in| j} tdgd|tdgd|d|jvxr| ddk(xr| dduxr| d  }|r!d }tj|t d | d<| d d k(rd}|j }td;i| }i}|jj}|jdd}t|jddhz }|r|r|j||d}nd}|r||j}n t|}|r:|jdd| d|d<|j!|j |||d}|j#ddD]\}}t%|j'}|j }d|jvr(|j)d|d<|dj}n t|}|r|s|j||d}|j+|j-||}||j.j1}|dj1}||j1|dz z } |rF|vrB||}!|j2r|j5}"n||zj}"||xx|"zcc<|j7|}#t9|#|j \}$}%|%| |z|%| z }|%| } | d|z dz |zz} ||z}t:j<j?t;j@| dt;j@|dg}&t;jB||&d }'|r|'||z z}'|'||<|jE||\}}(|r|jE|d!k(rdn|\}}$|d"k(rd#ndtFjHf})|d"k(rc|jJjM}*|*d} |*d}| jO| j5|jP| jSzf}+ng}+|r%d|jvr|d$k(r |d%k(rd&nd'},n |rd&},nd(},nd},| j)d)|,}-g}.|j#dd*D]\}}$t%|j'}||jUdjW}'tGjX|(|}/|j7|}#d|jvr|j[|d}0n| }0|j]| ||||0|-}1|d%k(r|j dk(r |#j^n |#j`}2|2|'d|'d|/z |'d|/fd+d,i|1}3|3D]v}4|j dk(r3|+|4jbjddd|)|4jbjfddE|)|4jbjddd|+|4jbjfddx|.ji|3n|d-k(r|'jjd.}5tGjl|'d|5d|5dz}6tGjl|'d|5d}7tGjl|/|/d.}8|j dk(rd/}9d0}:n#d/}9d1}:n|d2k(r|'d|'ddz z}6|'d}7|/}8d}9d}:|j dk(re|r|#jn687fd-9i|1};n|#jp67fd3:i|1\};|+|;jbjddd|)|;jbjfddnd|r|#jr687fd-9i|1};n|#jp76fd3:i|1\};|)|;jbjddd|+|;jbjfdd|.jm|;|s |}!|!jJ}n|!|tw|0d| d4<|#jp|=i| \}@|>|>@jbjddd|?|?@jbjfdd|d%k(rd5| vrt;jx|j'D$Acgc]\}$}A|AjJjM!c}A}$jWd6}B|Bdj{}C|BjP|Cdf}D|BjP|Cdf}Et|jH}F|j#D]\}}$|j7|}#|#jd7|#jjz t|#jjEDzgdz|#jj|Egdzz z\}G}H|j dk(rG}InH}ItOd8IzF}F|.D]F}4|4j}J|sJd9z}JtOFJ}K|sd&}Lt5K|L}K|4jKH|j |jn"|jjjd}#d:x}M}N|j dk(r|j.j}N|j dk(r|j.j}M|j|#MNd|jvr| r|s|d%k(r$ttjj};n%ttjjgg};|j |jn |j}O|j|O|;||||-| iyyy#tt$rYwxYwcc}A}$w)>((*ll9d3 !$..1S#J> #66xNK ;2&??,Lx=L    ua ($0$>GL !88""# 9I#'..t."L1 # Hh()C''FDNN*%-\\)%<"&x0446 !(m (K#66xN&&yx'QRC)..)224G\**,FK((*VaZ7Esi'#C.'' ' I!(6!1 6 6 8I#)+)B-b$2D2DEFAs(3u:5FJEQZ1,v55E f FMM--W-h//E99WE BD l22#JsOc1 #h!% 6 6z8 L I 118w#64HLIq !)F 2fBFF v !''002HW%Eh'F  fjj88K K &8w+>&-&7S  " # M Wm4  >>%>>n 6KHa()Cc?)))4@@BDZZ #/F)B& MM(5/: ! ))$9eJ& '+&8&8C&?BFFRWW #MOf,N  !  ! #5  u%%,&+O&+O%(_(<>O$P!) Q.$ -!$ 1 1 3 !S(M 1=A $&M #I} =I!!), -&+TWW1A1A1F1Fq1I "" I    $!113I    $!113I b)Y7 DNN "vw&( !2!23 !1!12r: $ 3TWWF   gx" (. "s 4's.m $m,  m)(m)c | in| j} tdi| } t|jddhz rF|jj }|r,| j |d|d|jddnd}g}|jdD]9\}}| |d|d|jdd\}}|j|;t|jddhz xs|}||r|j||}| jdd|rI||j||}n6| jd tttj|}nd}|d }|jd dD]\}}|j r| |d|d|jdd \}\}}|j#|}t%|d\}}t%|d\}}||}||}| j&d k7r|r|t)|t)z z}| j}d |jvr+|j+|d }|j-|}||d<nH|jdd}t/|t0rt3|d}n||j-|}||d<|s||j||}|||d <|s|r|j||}| tj4j7||}t9|j:j=Dcgc]}|j?c}}t9|j@j=Dcgc]}|j?c}} |jB|||jDfi|}!|2g|!jFjHddg|!jFjJdd|r|jLjN|!| |fi| |r|jQdd| s|jQdd|jR |jRn"|jTjVjXd}|j[|d |jvre|rbi}t]t^j`jb}"|jR |jRn |jT}#|je|#|"dddd|iyyycc}wcc}w)Nr0r=rFTrvminrvmaxC0r1rr cmapas_cmaprrrrO)3ror r@r5rrdefine_bin_paramsrrrSrrrrFr$rrxemptyr%rr rrPrrTstrrmamasked_less_equalanyxaxis get_gridlines get_visibleyaxis pcolormeshTr1r0r=r:colorbargridrAr)rVrBrDrrUrErFrh)$r8rIrthreshpthreshpmaxrLr#r$r%r&rrMrr full_heightsrr sub_heightscommon_color_normrsrrx_edgesy_edgesrAinv_xinv_yrarulx_gridy_gridmeshr]r\s$ r:plot_bivariate_histogramz-_DistributionPlotter.plot_bivariate_histograms")2x}}- -  t~~ #s +~~,,.H++SMSMLLD1  K >>>> -KAx& x}hll9d.KNK    ,  - !$DNN 3sCj @@OK  #4,,\7CFFA& ..|TB||FCBFFL0I,JKD =E#'..t."LP ( Hh~~+4   Y5+ 'G'gw)B0C8HAu/C8HAuGnGGnG~~([3x=3x=88"J& huo6,,U3%) 6"!~~fd3dC((t|||fi|} n|j6||fi|\} || j8j:dd|| j8j<ddT|j@ |j@n"|jBjDjFd }dx}}|jdk(rd}|jdk(rd}|jI|||d|jvr|r|r$tKtjLjN} n%tKtjjgg} |j@ |j@n |jB}|jQ|| |d||| iyyy#t,$rYowxYw)Nrlr!)rrmr^r0r=Tr^rrrrrrr`r1rFrDensity))rUrprqrGrHrrr?r@r5rrGrrxr)rr+r$rFrrrr6r%rPrRr3r4r1r0r=r5rAr)rVrBrDrrErFrh)r8r!rrrr^rLr#rrMr]subsetsrrsticky_densitysticky_supportrZr`rrrrr fill_fromrAr]rarnror\s r:plot_univariate_densityz,_DistributionPlotter.plot_univariate_densitys <00D __33FYY%%F#Hf5  $>Is4>>*c3Z78 x#44K44          $55iJ 9$,v#5Arvv; v &__002IOO4G4G4IINN 7" # # M Wm4 >>%>>* :KHa()C #C.mmG!#I)B& MM(5/: ! ))$xEJ dnn$,R__WiWJWF&bgggwE*EGF+9##%%a(+9##%%a(-R--gy'XZXF%bgggwE*EGF+9##%%a(+9##%%a(U* :\+TWW1A1A1F1Fq1I "" I    $!I    $!I b)Y7 DNN "v !2!23 !1!12r: $ 3TWWF   eXuh (. "a  s"N$$ N10N1c " | j} tdi| } t|jddhz sd}|jj }ii}}|j ddD]%\}}|ddg}|jjdj}|d|df}d|jvr|d}nd}tj|d} |s | |d|i\}}|r!d }|rtj |t"d |j%|}t'|d\}}t'|d\}}|d||d f}|rt)|t)|z z}t+|j-}||<|||<(|d}t/|t0rtj2|d |}n't|dkst5|d kDr t7d |r:|j9t;|j=|}|D cic]} | |}!} n3|j-D "cic]\} }"| |j9|"|}!} }"d|jvr=dD]7}#|#| vs|#d}tj |t"| j?|#9njt| ddhz}$|r|$s|jA|}%|%| d<|s|$s|g| d<| j?dd}%t/|%tBr tE|%d}%|%|%| d<|j dD]\}}d|vr1|jG|d}|r|jA|| d<n|g| d<|j%|}|r |jH}&n |jJ}&t+|j-}||vr||}||\}'}(| j?dd|&|'|(|fd|!|i| })|s| in| } |jLjN|)| |fi| |jP |jPn"|jRjTjVd}|jY|d|jvr|ri}*|r$t[t\j^j`}+n%t[t\jbjdgg}+|jP |jPn |jR},|jg|,|+|ddd |*iyyy#tjj$rd}YwxYwcc} wcc}"} w)Nr0r=Fr1TrrrzoKDE cannot be estimated (0 variance or perfect covariance). Pass `warn_singular=False` to disable this warning.rrrzlevels must be in [0, 1])rurz* parameter ignored when using hue mapping.rurrvlabelrQrrO)4ror r@r5rrrrrr+rrrxrrrrrr%rrrrrTrrr$ ValueErrorrlistrrFrrzrrPcontourfcontourr:rrAr)rVrBrDrrUrErFrGrHrh)-r8rr^rQrrLr#r$rr%r&r contour_kwsrrrsupportsrrr min_variancerrrrrrArrrr common_levelsr draw_levelsdparamcoloring_givenru contour_funcryycsetrar]r\s- r:plot_bivariate_densityz+_DistributionPlotter.plot_bivariate_densitysU "&&( ',' 4>>"c3Z/K>>((*!"8 "&..t."L, $ Hh$S#J/L'++-44Q7;;=L',l3.??LDNN*"9-||L!4H '0,'P'P$GW J!MM#{qA)B/C8HAu/C8HAuGAJ'wqz)::G3x=3x=88()C$IcN#HSMY, $^ >F ff %[[F3F6{Q#f+/ !;<<  33Y%%'(&M6??1m+?K?&OO-Aq4**1f55K DNN "+ +K'"G#MNCMM#{3OOE*  +!-0BBNN,,U3&* F#). H%??640D$$$T48&* F# >>%0' BKHa  huo6*.*?*?*FK'-2GK))B !{{ !zz ()C)#nGc]FB OOGT *B"3'D!)!12x" ""4"AAO' BT+TWW1A1A1F1Fq1I b! DNN "v J !2!23 !1!12r: $ 3TWWF   eWaR (. "o99((   T@s S  T4T  TTc Vtdi|}tdd}||j|d<|jdddD]T\}}|jr||j}|j dd} ||| \} } |j } d|jvr|j|d| d <|j|} t| |j\}}|| } t|jtjjrt j" | d <|jd k(r| | f}d }n| | f}d }|j$dk(r t'|}nd}| j(|i| \}t+|j,|}d |f|ddW|j. |j.n"|j0j2j4d } |j$j7} dx}}|jd k(r| }|jd k(r| }|j9| ||d|jvrw|rtt;tj<j>gg}|j dd}|j. |j.n |j0}|jA||ddd||iyyy)Nrrr0r=rr1T)rrrrrLrr0r=r rrr`FrO)!r rXrGrryrror5rPr%rrT__self__rUscale LogTransformrxr)r rr4getattrr1rAr)rVrBrCrDrrGrHrh)r8rr#rMr drawstylesrrrrr valsrarArrV plot_args stat_variabletop_edger]r1rnror`r\s r:plot_univariate_ecdfz)_DistributionPlotter.plot_univariate_ecdfs(<( LK8 *4+=+= >#'.. 4#1# * * Hh ~~#D$6$67Lll9d3G"<AJD$"J&&*mmHUO&D 7#)B-b$2D2DEFAst9D#,, (>(>?66'Q!!S( $J #  $J # ~~(|,bggy7J7GF"6#6#6 FLkLOU* *Z+TWW1A1A1F1Fq1I~~((* "" I    $I    $I b)Y7 DNN "vSYY--r26FLL!,E $ 3TWWF   udE8R  (. "r;c |jdD]W\}}|j|}|jdd|rR|j\}} d|jvr| |dzz } d|jvr||dzz }|j|| d |jvr$|j d d|j d dd|jvr|j |d|||d|jvr|j |d||||j|d |jvs|sttjjgg} |j|| d d ddiiZy) NTrrrr0rr=rr1crLF) rr%rrmarginsr5rF_plot_single_rugrDrrUrGrHrh) r8heightexpand_marginsr#rfrrrAxmargymarg legend_artists r:plot_rugz_DistributionPlotter.plot_rugsT#'>>>#F  Hh)B NN; *!zz| u$..(VaZ'E$..(VaZ'E Ue ,&T"&dnn$%%hVREdnn$%%hVRE  ! !" %&6 ' (8(8"b A    ueT1b"9 r;c||}t|}t||\}} | |}d|jvr|j|d} nd} |dk(rkt j |j |j} tjtj|dtjd|g|g} |dk(rkt j |j|j } tjtjd|g|tj|dg}  j|ddg} |jt| f | d||j|dk(|dk(y) z*Draw a rugplot along one axis of the plot.r1Nr0rrr=)r>r)scalexscaley)rrr5rPtxblended_transform_factoryr= transAxesrx column_stackrepeattilereshapeadd_collectionrr9)r8rrrrArfvectorrrrVrtransxy_pairs line_segss r:rz%_DistributionPlotter._plot_single_rug#s]# K*"c23V DNN "]]8E?3FF #:00r||LE &!$bggq&k1&=(H #:00r||LEF Q'61)=(H $$aAY/  .  !&v 9<   C3J?r;)T)__name__ __module__ __qualname__wide_structureflat_structurer7propertyrBrGrIrhrRrrrrrrprrrrrr __classcell__)r9s@r:r/r/cs$Z8N9%N966==66 !F. 7A!Z H\jX [zAFtlEN D$@r;r/r rFTrrj) r0r=r1rr rr binrangerrrIrr!r_r^rJr+rKrLrrrr$r%r&palette hue_orderhue_normrLr"r#rAc  8t|t||||}"|"j|||| tj} |"j | ||"j r:|r|dk(r | jn | j}#n | j}#t|#|||!}|"js| S| |"j} t||||| | }$|"j r!|"jd | |||| | |||||$|d |!| S|"jd | | |||||||||$d |!| S) Nr0r=r1rr3rordernormr"rj)r rr rrr) r!r_r^rJrrIr+rKrLr#rrL) rIrrrrrLr#r$r%r&rrO)r/rXmap_huepltgca_attachrBr/r3r4rrIrrpr)%r4r0r=r1rr rr rrrrIrr!r_r^rJr+rKrLrrrr$r%r&rrrrLr"r#rAkwargspmethodrs% r:rrNsg*  aS': A IIgYXI> z WWYIIbII&|| &&0RVVbooFWWFvsE6: == &&(   L ||### ##%  B I #"" ##%   Ir;aJPlot univariate or bivariate histograms to show distributions of datasets. A histogram is a classic visualization tool that represents the distribution of one or more variables by counting the number of observations that fall within discrete bins. This function can normalize the statistic computed within each bin to estimate frequency, density or probability mass, and it can add a smooth curve obtained using a kernel density estimate, similar to :func:`kdeplot`. More information is provided in the :ref:`user guide `. Parameters ---------- {params.core.data} {params.core.xy} {params.core.hue} weights : vector or key in ``data`` If provided, weight the contribution of the corresponding data points towards the count in each bin by these factors. {params.hist.stat} {params.hist.bins} {params.hist.binwidth} {params.hist.binrange} discrete : bool If True, default to ``binwidth=1`` and draw the bars so that they are centered on their corresponding data points. This avoids "gaps" that may otherwise appear when using discrete (integer) data. cumulative : bool If True, plot the cumulative counts as bins increase. common_bins : bool If True, use the same bins when semantic variables produce multiple plots. If using a reference rule to determine the bins, it will be computed with the full dataset. common_norm : bool If True and using a normalized statistic, the normalization will apply over the full dataset. Otherwise, normalize each histogram independently. multiple : {{"layer", "dodge", "stack", "fill"}} Approach to resolving multiple elements when semantic mapping creates subsets. Only relevant with univariate data. element : {{"bars", "step", "poly"}} Visual representation of the histogram statistic. Only relevant with univariate data. fill : bool If True, fill in the space under the histogram. Only relevant with univariate data. shrink : number Scale the width of each bar relative to the binwidth by this factor. Only relevant with univariate data. kde : bool If True, compute a kernel density estimate to smooth the distribution and show on the plot as (one or more) line(s). Only relevant with univariate data. kde_kws : dict Parameters that control the KDE computation, as in :func:`kdeplot`. line_kws : dict Parameters that control the KDE visualization, passed to :meth:`matplotlib.axes.Axes.plot`. thresh : number or None Cells with a statistic less than or equal to this value will be transparent. Only relevant with bivariate data. pthresh : number or None Like ``thresh``, but a value in [0, 1] such that cells with aggregate counts (or other statistics, when used) up to this proportion of the total will be transparent. pmax : number or None A value in [0, 1] that sets that saturation point for the colormap at a value such that cells below constitute this proportion of the total count (or other statistic, when used). {params.dist.cbar} {params.dist.cbar_ax} {params.dist.cbar_kws} {params.core.palette} {params.core.hue_order} {params.core.hue_norm} {params.core.color} {params.dist.log_scale} {params.dist.legend} {params.core.ax} kwargs Other keyword arguments are passed to one of the following matplotlib functions: - :meth:`matplotlib.axes.Axes.bar` (univariate, element="bars") - :meth:`matplotlib.axes.Axes.fill_between` (univariate, other element, fill=True) - :meth:`matplotlib.axes.Axes.plot` (univariate, other element, fill=False) - :meth:`matplotlib.axes.Axes.pcolormesh` (bivariate) Returns ------- {returns.ax} See Also -------- {seealso.displot} {seealso.kdeplot} {seealso.rugplot} {seealso.ecdfplot} {seealso.jointplot} Notes ----- The choice of bins for computing and plotting a histogram can exert substantial influence on the insights that one is able to draw from the visualization. If the bins are too large, they may erase important features. On the other hand, bins that are too small may be dominated by random variability, obscuring the shape of the true underlying distribution. The default bin size is determined using a reference rule that depends on the sample size and variance. This works well in many cases, (i.e., with "well-behaved" data) but it fails in others. It is always a good to try different bin sizes to be sure that you are not missing something important. This function allows you to specify bins in several different ways, such as by setting the total number of bins to use, the width of each bin, or the specific locations where the bins should break. Examples -------- .. include:: ../docstrings/histplot.rst returnsseealso)r'rrscottr g?r)r0r=r1rrrrrLr^r!rrr bw_method bw_adjustrr"rQrgridsizer rvr#r$r%r&rAc >d|vr d}t||jdd}|G|rd}|||}}n||}}nd}tjd|d}t j |t d |jd d} | 7tjd | d }t j |t d | }|jd d1tjd}t j |t d |jdd}!|!9|!rd}tjd|d}t j |t d |jdd}"|"7|"} tjd|"d}t j |td |jd|}t|t||||}#|#j||||tj}|#j|ddg|| r |jn |j}$t!|$|||}|#j"s|St|||||| }%|#j$r-|j'}&|#j(d | | | | ||||%d|&|S|#j*d | | |||||||||%d ||S)!Ndata2zD`data2` has been removed (replaced by `y`); please update your code.verticalassigning data to `y`.assigning data to `x`.2 The `vertical` parameter is deprecated; X This will become an error in seaborn v0.14.0; please update your code. rrbwzo The `bw` parameter is deprecated in favor of `bw_method` and `bw_adjust`. Setting `bw_method=z`, but please see the docs for the new parameters and update your code. This will become an error in seaborn v0.14.0. kernelz Support for alternate kernels has been removed; using Gaussian kernel. This will become an error in seaborn v0.14.0; please update your code. shade_lowestrzH `shade_lowest` has been replaced by `thresh`; setting `thresh=zY. This will become an error in seaborn v0.14.0; please update your code. shadezF `shade` is now deprecated in favor of `fill`; setting `fill=zZ`. This will become an error in seaborn v0.14.0; please update your code. n_levelsrr3rnumericdatetime allowed_typesr")rrrr rvr)r!rrr^rLr#rr) rr^rQrr#rLrr$r%r&rrO) TypeErrorrFtextwrapdedentrrr FutureWarningr/rXrrrrr3r4rrIrBrorr)'r4r0r=r1rrrrrLr^r!rrrrrrr"rQrrr rvr#r$r%r&rArrr action_takenrrrrrrrMs' r:rr-s &Tnzz*d+H 3LyTa!13Loo#11=?     c;15 D$ B ~oo#4     c;15 zz(D!-oo    c;15::nd3L Foo#GGMhO     c;15 JJw %E oo#EEJGL     c=Q7 ZZ F +F  aS': A IIgYXI> z WWYIIbJ 79IM $R__"''F 63v 6E ==    L ||;;=!!! ##'%  : I !  #'%   Ir;aPlot univariate or bivariate distributions using kernel density estimation. A kernel density estimate (KDE) plot is a method for visualizing the distribution of observations in a dataset, analogous to a histogram. KDE represents the data using a continuous probability density curve in one or more dimensions. The approach is explained further in the :ref:`user guide `. Relative to a histogram, KDE can produce a plot that is less cluttered and more interpretable, especially when drawing multiple distributions. But it has the potential to introduce distortions if the underlying distribution is bounded or not smooth. Like a histogram, the quality of the representation also depends on the selection of good smoothing parameters. Parameters ---------- {params.core.data} {params.core.xy} {params.core.hue} weights : vector or key in ``data`` If provided, weight the kernel density estimation using these values. {params.core.palette} {params.core.hue_order} {params.core.hue_norm} {params.core.color} fill : bool or None If True, fill in the area under univariate density curves or between bivariate contours. If None, the default depends on ``multiple``. {params.dist.multiple} common_norm : bool If True, scale each conditional density by the number of observations such that the total area under all densities sums to 1. Otherwise, normalize each density independently. common_grid : bool If True, use the same evaluation grid for each kernel density estimate. Only relevant with univariate data. {params.kde.cumulative} {params.kde.bw_method} {params.kde.bw_adjust} warn_singular : bool If True, issue a warning when trying to estimate the density of data with zero variance. {params.dist.log_scale} levels : int or vector Number of contour levels or values to draw contours at. A vector argument must have increasing values in [0, 1]. Levels correspond to iso-proportions of the density: e.g., 20% of the probability mass will lie below the contour drawn for 0.2. Only relevant with bivariate data. thresh : number in [0, 1] Lowest iso-proportion level at which to draw a contour line. Ignored when ``levels`` is a vector. Only relevant with bivariate data. gridsize : int Number of points on each dimension of the evaluation grid. {params.kde.cut} {params.kde.clip} {params.dist.legend} {params.dist.cbar} {params.dist.cbar_ax} {params.dist.cbar_kws} {params.core.ax} kwargs Other keyword arguments are passed to one of the following matplotlib functions: - :meth:`matplotlib.axes.Axes.plot` (univariate, ``fill=False``), - :meth:`matplotlib.axes.Axes.fill_between` (univariate, ``fill=True``), - :meth:`matplotlib.axes.Axes.contour` (bivariate, ``fill=False``), - :meth:`matplotlib.axes.contourf` (bivariate, ``fill=True``). Returns ------- {returns.ax} See Also -------- {seealso.displot} {seealso.histplot} {seealso.ecdfplot} {seealso.jointplot} {seealso.violinplot} Notes ----- The *bandwidth*, or standard deviation of the smoothing kernel, is an important parameter. Misspecification of the bandwidth can produce a distorted representation of the data. Much like the choice of bin width in a histogram, an over-smoothed curve can erase true features of a distribution, while an under-smoothed curve can create false features out of random variability. The rule-of-thumb that sets the default bandwidth works best when the true distribution is smooth, unimodal, and roughly bell-shaped. It is always a good idea to check the default behavior by using ``bw_adjust`` to increase or decrease the amount of smoothing. Because the smoothing algorithm uses a Gaussian kernel, the estimated density curve can extend to values that do not make sense for a particular dataset. For example, the curve may be drawn over negative values when smoothing data that are naturally positive. The ``cut`` and ``clip`` parameters can be used to control the extent of the curve, but datasets that have many observations close to a natural boundary may be better served by a different visualization method. Similar considerations apply when a dataset is naturally discrete or "spiky" (containing many repeated observations of the same value). Kernel density estimation will always produce a smooth curve, which would be misleading in these situations. The units on the density axis are a common source of confusion. While kernel density estimation produces a probability distribution, the height of the curve at each point gives a density, not a probability. A probability can be obtained only by integrating the density across a range. The curve is normalized so that the integral over all possible values is 1, meaning that the scale of the density axis depends on the data values. Examples -------- .. include:: ../docstrings/kdeplot.rst proportion) r0r=r1rr  complementaryrrrr"r#rAc t|t||||}|j||| | tj} |j | | | j d| j dd}t| j||| | d<|js| S|js tdt||}|jd || d | | S) Nrr3rrrLr(Bivariate ECDF plots are not implemented)r r)rr#rO) r/rXrrrrrFrr4rIrBNotImplementedErrorr)r4r0r=r1rr rrrrr"r#rArrrLrs r:rrEs  aS': A IIgYXI> z WWYIIbII& JJw 3 5 6E$RWWc5&AF7O ==  <<!"LMM #L A!  Ir;arPlot empirical cumulative distribution functions. An ECDF represents the proportion or count of observations falling below each unique value in a dataset. Compared to a histogram or density plot, it has the advantage that each observation is visualized directly, meaning that there are no binning or smoothing parameters that need to be adjusted. It also aids direct comparisons between multiple distributions. A downside is that the relationship between the appearance of the plot and the basic properties of the distribution (such as its central tendency, variance, and the presence of any bimodality) may not be as intuitive. More information is provided in the :ref:`user guide `. Parameters ---------- {params.core.data} {params.core.xy} {params.core.hue} weights : vector or key in ``data`` If provided, weight the contribution of the corresponding data points towards the cumulative distribution using these values. {params.ecdf.stat} {params.ecdf.complementary} {params.core.palette} {params.core.hue_order} {params.core.hue_norm} {params.dist.log_scale} {params.dist.legend} {params.core.ax} kwargs Other keyword arguments are passed to :meth:`matplotlib.axes.Axes.plot`. Returns ------- {returns.ax} See Also -------- {seealso.displot} {seealso.histplot} {seealso.kdeplot} {seealso.rugplot} Examples -------- .. include:: ../docstrings/ecdfplot.rst g?) r0r=r1rrrrrr#rAc  f| jdd} | jdd} | 3| }tjd}tj|t d| F| dk(r|}n| dk(r|}d}tjd| d }tj|t d| jd d}|G|rd }|||}}n||}}nd }tjd |d}tj|t dt |t|||}|j|||| tj} |j| | jd| jdd}t| j||| | d<|js| S|j||| fi| | S)Nrrz The `a` parameter has been replaced; use `x`, `y`, and/or `data` instead. Please update your code; This will become an error in seaborn v0.14.0. rrr0r=z= The `axis` parameter has been deprecated; use the `zl` parameter instead. Please update your code; this will become an error in seaborn v0.14.0. rrrrr)r0r=r1r3rrLr)rFrrrrrr/rXrrrrrr4rIr)r4r0r=r1rrrrrr#rArrrrrrrrLs r:rrs"  3A ::fd #D}oo    c;15  3;A S[Aoo#<<@6B     c;15zz*d+H 3LyTa!13Loo#11=?     c;15  aS) AIIgYXI> z WWYIIbM JJw 3 5 6E$RWWc5&AF7O == AJJv~v88 Ir;aGPlot marginal distributions by drawing ticks along the x and y axes. This function is intended to complement other plots by showing the location of individual observations in an unobtrusive way. Parameters ---------- {params.core.data} {params.core.xy} {params.core.hue} height : float Proportion of axes extent covered by each rug element. Can be negative. expand_margins : bool If True, increase the axes margins by the height of the rug to avoid overlap with other elements. {params.core.palette} {params.core.hue_order} {params.core.hue_norm} legend : bool If False, do not add a legend for semantic variables. {params.core.ax} kwargs Other keyword arguments are passed to :meth:`matplotlib.collections.LineCollection` Returns ------- {returns.ax} Examples -------- .. include:: ../docstrings/rugplot.rst )r'rr,)r0r=r1rrrkindrugrug_kwsr"r#rrrrLcol_wrap row_order col_orderraspect facet_kwsc t|t||||||}|j| | |tdgd|d|vri}!| j1D]\}"}#|$j|"|#|!|"<|!|$d<||$d<|j6r.t)|$|j@t>|j@d!i|$nt)|$|jBt>|jBd!i|$n|dk(r|j'}%i}!i} t)| tDj,tF| j1D]\}"}#|%j|"|#|!|"<|!|%d<||%d<|j6r.t)|%|jHtF|jHd!i|%n tKd|r=| i} t)| |jLtNd| d<||| d<|jLd!i| |jQ|jjd|jRjTdjW|jjd|jRjTdjY|j[|j]|||t_|t`jbstajb|}tajd||jf|jfjji|jdd |_3|S|jj1D&'cic]\}&}'|&|'d |&d n|'}(}&}'|jj|( |_3|Scc}'}&w)"N)r0r=r1rrrr3rr)r,r+r-rAzg`displot` is a figure-level function and does not accept the ax= parameter. You may wish to try {}plot.)rrr)rrr)r4rrrrrrrr+rrrrtr#r,rrrLr-r Fr0rr=)x_vary_varT) left_index right_indexrO)5r/rXrrformatrrrrFr5rr.r,r duplicatedrrrrIrorr r7rrrrrrBrprr rrrr rrr rrset_axis_labelsrVrB get_xlabel get_ylabel set_titles tight_layoutrTrrmerger4 difference))r4r0r=r1rrrrrrr"r#rrrrLrrrrrrrrrr grid_datacol_namerow_namerrhist_kwsestimate_defaultsrr default_valrKecdf_kwsrr wide_colss) r:rr.s  aS'sL A IIgYXI>F3T:  v~ ==CVD\   c;' 4* !++ !++c"2":!"3%qzAKK *  ""1;;"7I a)"3"3">">"@!@@AI{{u%H{{u%H   H(YF     A u}"J/  IIa} IB == }F8 v~;;=0)2D2DhO 1 7 7 9 ? C ( S+ >L  ?  # +'(':':' C ' C =L  >#/  << "7A,E,Ew O %A % % 0 0 #7A,D,Dg N $A $ $ /w / ;;= 0$--J 1 7 7 9 ? C ( S+ >L  ?$0 ! << "8Q-C-CX N "A " " .X .&&PQ Q ?Gw G<!  $GG  Wkkooc166;;q>#<#<#>?kkooc166;;q>#<#<#>?LLNNN Q]am$ -<<%D  FF166>>,,T\\: ;   H 9: 8I8I8K 041A191#Qx! +  ##I#6 H  s7W2a Figure-level interface for drawing distribution plots onto a FacetGrid. This function provides access to several approaches for visualizing the univariate or bivariate distribution of data, including subsets of data defined by semantic mapping and faceting across multiple subplots. The ``kind`` parameter selects the approach to use: - :func:`histplot` (with ``kind="hist"``; the default) - :func:`kdeplot` (with ``kind="kde"``) - :func:`ecdfplot` (with ``kind="ecdf"``; univariate-only) Additionally, a :func:`rugplot` can be added to any kind of plot to show individual observations. Extra keyword arguments are passed to the underlying function, so you should refer to the documentation for each to understand the complete set of options for making plots with this interface. See the :doc:`distribution plots tutorial <../tutorial/distributions>` for a more in-depth discussion of the relative strengths and weaknesses of each approach. The distinction between figure-level and axes-level functions is explained further in the :doc:`user guide <../tutorial/function_overview>`. Parameters ---------- {params.core.data} {params.core.xy} {params.core.hue} {params.facets.rowcol} weights : vector or key in ``data`` Observation weights used for computing the distribution function. kind : {{"hist", "kde", "ecdf"}} Approach for visualizing the data. Selects the underlying plotting function and determines the additional set of valid parameters. rug : bool If True, show each observation with marginal ticks (as in :func:`rugplot`). rug_kws : dict Parameters to control the appearance of the rug plot. {params.dist.log_scale} {params.dist.legend} {params.core.palette} {params.core.hue_order} {params.core.hue_norm} {params.core.color} {params.facets.col_wrap} {params.facets.rowcol_order} {params.facets.height} {params.facets.aspect} {params.facets.facet_kws} kwargs Other keyword arguments are documented with the relevant axes-level function: - :func:`histplot` (with ``kind="hist"``) - :func:`kdeplot` (with ``kind="kde"``) - :func:`ecdfplot` (with ``kind="ecdf"``) Returns ------- {returns.facetgrid} See Also -------- {seealso.histplot} {seealso.kdeplot} {seealso.rugplot} {seealso.ecdfplot} {seealso.jointplot} Examples -------- See the API documentation for the axes-level functions for more details about the breadth of options available for each plot kind. .. include:: ../docstrings/displot.rst ctj|}t|dkrytjj tj |ddg}d|zt|dzz }|dk(r(t tj|jSt tj|j|jz |z S)z;Calculate number of hist bins using Freedman-Diaconis rule.rrKgUUUUUU?r) rxryrsubtractreduce nanpercentilersqrtsizeceilr$r+)riqrrs r:_freedman_diaconis_binsr6G s 1 A 1vz ++  R--a"b: ;C C3q6e$%AAv277166?##277AEEGaeeg-2344r;cB!|r|sd}nd}tjd|d}tj|td|t j }t| }| t|dr|j} | d }||}tj|t}|jd kDr|j}t|}| xs|xsdu} |in|j!}|in|j!}|in|j!}| in| j!} | g| r#|j#d |j%\}n"|j#|j%d \}|j'} |j)||r||d <n|r||d <n|r||d <nr|| d <|rt|t+t-|d }|j/dd|j/d| | rdnd}|j1d| }|j2||f||d||| k7r||d<| rdnd}|r0|j1d| }t5d i||i||d||| k7r||d<|r0|j1d| }t7d i||i||d||| k7r||d<!fd}| j1dd}| j1dd}| j1dd}| j1dtj8 tj8f}t;|j=|j?d z}tA|||||}jC|!||} | r| |} }|j"|| fd|i| |dk7r|| d<|r&| r|jE| |S|jG| |S)!ad DEPRECATED This function has been deprecated and will be removed in seaborn v0.14.0. It has been replaced by :func:`histplot` and :func:`displot`, two functions with a modern API and many more capabilities. For a guide to updating, please see this notebook: https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 z;`kdeplot` (an axes-level function for kernel density plots)z2`histplot` (an axes-level function for histograms)z `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or z. For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 rrNrTrrr2r`g?r horizontalrrL) orientationrLr=r0)rArLc*j|gSN)pdf)r0fitr's r:r=zdistplot..pdf s3771&v& &r;z#282828rrr rrv)ddofrO)$rrrrrrrr?hasattrrrxryfloatndimsqueezerror4mean get_colorremover+r6rrrFr,rrr)r scotts_factorstdrr> set_ylabel set_xlabel)"rrr,r+rr>r'rKrfit_kwsrLr norm_histaxlabelrrAr0axes_level_suggestionrlabel_axrdr: hist_colorr kde_color rug_colorr= fit_colorrr rvrr=r's" ` @r:r r V s" 4 I  A  // 334  C MM#{q1 z WWYG}H71f-&&  H }  1eAvvz IIK ! A5S5S_I%r8==?HObGObGObG } GGAqvvx(EDGGAFFHa(ED     %HW  $GG  $GG  $GG  <.q126DGS)Iy1&.lJ \\'51 4 .[  .$, .   *HW 3D KK/ ?4)?)?w?  (GG  KK/ ?4)?)?w?  (GG   'KK3 ;;z3/kk%#{{6RVVGRVV#45 !_ * * ,quu!u} < B#t 4 F aqA11I11  !(GG   MM' " I MM' " Ir;r<)NNTTFNNNNNNFFNNNN)E__doc__numbersr functoolsrrrrnumpyrxpandasr matplotlibrUmatplotlib.pyplotpyplotrmatplotlib.transforms transformsrmatplotlib.cbookrmatplotlib.colorsrmatplotlib.collectionsr_baser _statisticsr r r _stats.countingr axisgridrrutilsrrrrrrpalettesrexternalr external.kder _docstringsrr__all__rX _dist_paramsfrom_nested_componentsfrom_function_paramsr7 _param_docsr/rrrrrrr6r rOr;r:rosh7 "-%1 .-!$& P      7 B9!88 H  { + \ *000> 1  1 1)2D2D E 1  1 1$-- @  d@=d@X' [ dd vt e4 f4 td dE4$ D4t4D![|zt F  y ! y ! u D UDdD D4t$ $Ee$$ cCQT eTDT Upyr F  y ! y ! sB 5 dd U D44D5p1b F  y ! y ! c r MDd4 D4M`#F F  y ! GT }  d$D$ UDD D4t TT Q$} @MZ F  y ! y ! [r 5EI@DBF$(Mr;