
    Le"                         d dl Zd dlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZ dd	lmZ  G d
 de          Z G d de          Z G d dee	          Z G d dee          Z G d de          ZdS )    N   )sorted_context   )MultiDistributionMixin   )AreaPlot	ChartPlot)PolygonPlot)AdjoinedPlotc                   ~    e Zd ZdZ ej        dd          Z ej        dd          Z ej        dd          Z	dS )	DistributionPlotzH
    DistributionPlot visualizes a distribution of values as a KDE.
    N>
        The bandwidth of the kernel for the density estimate.defaultdocr   D
        Draw the estimate to cut * bw from the extreme data points.T9
        Whether the bivariate contours should be filled.)
__name__
__module____qualname____doc__paramNumber	bandwidthcutBooleanfilled     <lib/python3.11/site-packages/holoviews/plotting/mpl/stats.pyr   r      s          T 0A B B BI %,q 'G H H HC U]4 .< = = =FFFr   r   c                       e Zd ZdZ ej        dd          Z ej        dd          Z ej        dd          Z	 ej
        d	eefd
          ZdS )BivariatePlotz
    Bivariate plot visualizes two-dimensional kernel density
    estimates. Additionally, by enabling the joint option, the
    marginals distributions can be plotted alongside each axis (does
    not animate or compose).
    Nr   r   r   r   Fr   
   zD
        A list of scalar values used to specify the contour levels.)r   class_r   )r   r   r   r   r   r   r   r   r   r   ClassSelectorlistintlevelsr   r   r    r"   r"      s          T 0A B B BI %,q 'G H H HC U]5 /< = = =F !U T3K FG H H HFFFr   r"   c                   H    e Zd ZdZg dZeZ ed          Zd Zd Z	d Z
dS )	BoxPlot
    BoxPlot plots the ErrorBar Element type and supporting
    both horizontal and vertical error bars via the 'horizontal'
    plot option.
    )notchsymwhis	bootstrapconf_intervalswidths	showmeans	show_caps
showfliersboxpropswhiskerpropscapprops
flierpropsmedianprops	meanpropsmeanlineboxplotsinglec                    |j         rYt          d          5  |                    |j                   j                                        }d d d            n# 1 swxY w Y   n
|j        |fg}g g }}|D ]\  }}|j         r3d                    d t          |j         |          D                       }	n|}	||j        d                  }
|	                    |
t          j        |
                              |	                    |	           ||d<   d |                                D             }| j         |d<   d |j         D             }|f|d	||j        d         gifS )
NF,c                 >    g | ]\  }}|                     |          S r   pprint_value.0dvs      r    
<listcomp>z$BoxPlot.get_data.<locals>.<listcomp>J   (    !X!X!X1!.."3"3!X!X!Xr   r   labelsc                 "    i | ]\  }}|d v	||S )zorderlabelr   rE   krG   s      r    
<dictcomp>z$BoxPlot.get_data.<locals>.<dictcomp>Q   3     2 2 2$!Q000 A000r   vertc                 :    g | ]}|                     d           S N)value_formatclonerE   kds     r    rH   z$BoxPlot.get_data.<locals>.<listcomp>T   &    LLLd33LLLr   
dimensions)kdimsr   groupbydataitemsrN   joinzipvdimsappendnpisfiniteinvert_axes)selfelementrangesstylegroupsr_   rJ   keygrouprN   rF   format_kdimss               r    get_datazBoxPlot.get_data@   s   = 	0&& E E 77<BBDDE E E E E E E E E E E E E E E }g./F2f  	! 	!JC} !X!XGMSV@W@W!X!X!XYYek!n%AKK"+a..)***MM%     h2 2%++-- 2 2 2 ,,fLLgmLLLw|W]1=M.NOOO   2AAAc                 6     |j         |i |}|d         |d<   |S )Nboxesartist)r<   )rh   ax	plot_argsplot_kwargsartistss        r    init_artistszBoxPlot.init_artistsW   s,    "*i7;77#G,r   c                 t    dD ]4}| j                             |g           D ]}|                                 5d S )Nwhiskersfliersmediansrs   capsmeanshandlesgetremove)rh   grG   s      r    teardown_handleszBoxPlot.teardown_handles\   sP    L 	 	A\%%a,,  



	 	r   N)r   r   r   r   
style_opts_nonvectorized_stylesdict_plot_methodsrp   ry   r   r   r   r    r*   r*   /   sy         : : :J 'D	***MP P P.  
    r   r*   c                        e Zd Z ej        dd          Z ej        dd          Z ej        dg dd	          Z	 ej        dg d
d	          Z
 fdZ xZS )SideBoxPlot)r   r   r   r   z(
        Make plot background invisible.r   r   zI
        The size of the border expressed as a fraction of the main plot.bare)topbottomr   ztop-barezbottom-bareNz
        Whether and where to display the xaxis, bare options allow suppressing
        all axis labels including ticks and xlabel. Valid options are 'top',
        'bottom', 'bare', 'top-bare' and 'bottom-bare'.)r   objectsr   )leftrightr   z	left-barez
right-bareNz
        Whether and where to display the yaxis, bare options allow suppressing
        all axis labels including ticks and ylabel. Valid options are 'left',
        'right', 'bare' 'left-bare' and 'right-bare'.c                 f     t                      j        |i | | j        r| j         | _        d S d S )N)super__init__adjoinedrg   )rh   argskwargs	__class__s      r    r   zSideBoxPlot.__init__x   sG    $)&)))= 	4#'#33D	4 	4r   )r   r   r   r   	Parameterbgcolorr   border_sizeObjectSelectorxaxisyaxisr   __classcell__)r   s   @r    r   r   b   s        eol 9+ , , ,G %,q /L M M MK !E *? *? *?E;< < <E !E *> *> *>D9: : :E4 4 4 4 4 4 4 4 4r   r   c                       e Zd ZdZ ej        dd          Z ej        g ddd          Z e	d	
          Z
g dZd eD             Zd Zd Zd ZdS )
ViolinPlotr+   Nzl
        Allows supplying explicit bandwidth value rather than relying
        on scott or silverman method.r   )boxr~   Nr   z
        Inner visual indicator for distribution values:

          * box - A small box plot
          * stick - Lines indicating each sample value
          * quartiles - Indicates first, second and third quartiles
        )r   r   r   
violinplotr=   )	r2   
facecolorsshowextrema	bw_methodr1   stats_color	box_coloralpha
edgecolorsc                     g | ]}|d v|	S ))r   r   r1   r   )rE   ss     r    rH   zViolinPlot.<listcomp>   s*       *P!P!P!P!P!Pr   c                    |                     dd          }|                     dd          }|                     dg           }|                     dd          }|                     d          }|                     dd          }	| j        d	k    }
| j        pd
} |j        |||
d|}| j        dk    r3 |j        ||d         dddd|iddid|d}|                    |           t          |d         |          D ]D\  }}|                    |           |                    |           |	                    |	           EdD ]!}||v r||                             |           "|d         |d<   |S )Nr   blackr   r   r   rJ   r   g      ?r~   scott)r   showmediansr   	positionsFT	facecolorcolorwhiteg?)r   r4   showcapspatch_artistr5   r9   r1   rJ   bodies)cmedianscmeanscmaxescminscbars)
popinnerr   r   r<   updaterb   set_facecolorsset_edgecolors	set_alpha)rh   ru   rv   rw   r   r   r   r   rJ   r   r   r   rx   r   bodyr   stats                    r    ry   zViolinPlot.init_artists   s   OOK99	!oomW== __\266
 __\7;;
**,,jI-N-g	"-i+6G G:EG G:"*i;{3K(-D'2I&>*17);C$*	, , ,C
 NN3wx0*== 	" 	"KD%&&&
+++NN5!!!!F 	: 	:Dw,,[999#H-r   c           	         |j         rYt          d          5  |                    |j                   j                                        }d d d            n# 1 swxY w Y   n
|j        |fg}g g g }}}|                     |d          }t          |          D ]\  }	\  }
}|j         r3d                    d t          |j         |
          D                       }n|
}||j
        d                  }|                    |t          j        |                              |                    |           |                    ||	                             dd                     t          t!          t#          |                              |d<   ||d	<   ||d<   |j        dk    r!|                    t          j        
          }n5|                    |                    t          j        
          fg          }|                     |||          }d |                                D             }| j         |d<   d |j         D             }| j        rdndt          t          |                    i}|f|t1          dd||j
        d         gi|fS )NFrk   r@   c                 >    g | ]\  }}|                     |          S r   rB   rD   s      r    rH   z'ViolinPlot.get_data.<locals>.<listcomp>   rI   r   r   r   bluer   rJ   )functionc                 "    i | ]\  }}|d v	||S rL   r   rO   s      r    rQ   z'ViolinPlot.get_data.<locals>.<dictcomp>   rR   r   rS   c                 :    g | ]}|                     d           S rU   rW   rY   s     r    rH   z'ViolinPlot.get_data.<locals>.<listcomp>   r[   r   yticksxticksr\   r   )r]   r   r^   r_   r`   rN   lookup_options	enumeratera   rb   rc   rd   re   rf   r   r&   rangelenndims	aggregatemeanrX   _apply_transformsrg   r   )rh   ri   rj   rk   rl   r_   rJ   colorselstyleirm   rn   rN   rF   	new_stylero   tickss                    r    rp   zViolinPlot.get_data   s   = 	0&& E E 77<BBDDE E E E E E E E E E E E E E E }g./F!2rff%%gw77(00 	@ 	@OA|U} !X!XGMSV@W@W!X!X!XYYek!n%AKK"+a..)***MM%   MM'!*..v>>????!%D		"2"233k h$l=1'''99GGmmg&7&7&7&I&I%K$LMMG**7FEBB	2 2)//"3"3 2 2 2 ,,fLLgmLLL!-;8T)FBSBS=T=TUwtYYgmA>N/OYSXYYYYrq   c                     d}d}||z   D ]4}| j                             |g           D ]}|                                 5d S )N)r   r   r   r   r   r   r{   r   )rh   box_artistsviolin_artistsrn   rG   s        r    r   zViolinPlot.teardown_handles   s_    RT / 	 	E\%%eR00  



	 	r   )r   r   r   r   r   r   r   r   r   r   r   r   r   ry   rp   r   r   r   r    r   r   ~   s          T 0) * * *I !E )A)A)A). 5  E D---MO O OJ     8!Z !Z !ZF    r   r   )numpyre   r   core.ndmappingr   mixinsr   chartr   r	   pathr
   plotr   r   r"   r*   r   r   r   r   r    <module>r      sn        , , , , , , + + + + + + & & & & & & & &            = = = = =x = = =H H H H HK H H H*0 0 0 0 0$i 0 0 0f4 4 4 4 4, 4 4 48a a a a a a a a a ar   