o
    �¨ÊhUG  ã                   @  sÆ  d dl mZ d dlmZmZmZ d dlZd dlmZ d dl	Z
d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlZd dlm  mZ d dlmZ d dlm Z m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z'm(Z(m)Z) er“d dl*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3 d8dd„Z4G dd „ d e ƒZ5d9d!d"„Z6			#	$				d:d;d)d*„Z7					 	#			d<d=d/d0„Z8					 	#			d<d=d1d2„Z9	#			 	#				$	#d>d?d6d7„Z:dS )@é    )Úannotations)ÚTYPE_CHECKINGÚLiteralÚ
NamedTupleN)Úsetp)Úlib)Úcache_readonly)Úfind_stack_level)Úis_dict_like)Ú	ABCSeries©Úremove_na_arraylike©Úpprint_thing)ÚLinePlotÚMPLPlot)Úcreate_iter_data_given_by)Úget_standard_colors)Úcreate_subplotsÚflatten_axesÚmaybe_adjust_figure)Ú
Collection)ÚAxes)ÚFigure)ÚLine2D)ÚMatplotlibColorÚaxr   Úlabelsú	list[str]Úis_verticalÚboolÚreturnÚNonec                 K  s‚   |r|   ¡ n|  ¡ }t|ƒt|ƒkr)tt|ƒt|ƒƒ\}}|dks%J |ƒ‚||9 }|r6| j|fi |¤Ž dS | j|fi |¤Ž dS )zãSet the tick labels of a given axis.

    Due to https://github.com/matplotlib/matplotlib/pull/17266, we need to handle the
    case of repeated ticks (due to `FixedLocator`) and thus we duplicate the number of
    labels.
    r   N)Ú
get_xticksÚ
get_yticksÚlenÚdivmodÚset_xticklabelsÚset_yticklabels)r   r   r   ÚkwargsÚticksÚiÚ	remainder© r-   úU/var/www/html/env/lib/python3.10/site-packages/pandas/plotting/_matplotlib/boxplot.pyÚ_set_ticklabels/   s   r/   c                      sî   e Zd Zed6dd„ƒZdZdZG dd„ deƒZd7d8dd„Z	e
		d9d:dd„ƒZdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed d!„ ƒZ		"d;d<d%d&„Zd=d'd(„Zd>d+d,„Zd=d-d.„Zd?d/d0„Zed@d2d3„ƒZe‡ fd4d5„ƒZ‡  ZS )AÚBoxPlotr!   úLiteral['box']c                 C  s   dS )NÚboxr-   ©Úselfr-   r-   r.   Ú_kindB   s   zBoxPlot._kindÚ
horizontal)NÚaxesÚdictÚbothc                   @  s   e Zd ZU ded< ded< dS )z
BoxPlot.BPr   r   zdict[str, list[Line2D]]ÚlinesN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r-   r-   r-   r.   ÚBPJ   s   
 r?   r7   Úreturn_typeÚstrr"   c                 K  sT   || j vr	tdƒ‚|| _tj| |fi |¤Ž | jr(| jdkr#d| _d S d| _d S d S )Nz2return_type must be {None, 'axes', 'dict', 'both'}ÚverticalF)	Ú_valid_return_typesÚ
ValueErrorr@   r   Ú__init__ÚsubplotsÚorientationÚsharexÚsharey)r4   Údatar@   r)   r-   r-   r.   rE   O   s   



úzBoxPlot.__init__Nr   r   Úyú
np.ndarrayc                 K  st   |j dkrdd„ |D ƒ}dd„ |D ƒ}nt|ƒ}|j|fi |¤Ž}|dkr)||fS |dkr6| j||d�|fS ||fS )Né   c                 S  ó   g | ]}t |ƒ‘qS r-   r   ©Ú.0Úvr-   r-   r.   Ú
<listcomp>f   ó    z!BoxPlot._plot.<locals>.<listcomp>c                 S  s(   g | ]}|j d kr|nt tjg¡‘qS )r   )ÚsizeÚnpÚarrayÚnanrO   r-   r-   r.   rR   j   s   ( r8   r9   ©r   r:   )Úndimr   Úboxplotr?   )Úclsr   rK   Ú
column_numr@   ÚkwdsÚysÚbpr-   r-   r.   Ú_plot`   s   
zBoxPlot._plotc                 C  sb   |t ju rd S |d urtjdtƒ d� t|tƒr/g d¢}|D ]}||vr.td|› d|› �ƒ‚q|S )NzC'color' and 'colormap' cannot be used simultaneously. Using 'color')Ú
stacklevel©ÚboxesÚwhiskersÚmediansÚcapsú!color dict contains invalid key 'ú'. The key must be either )r   Ú
no_defaultÚwarningsÚwarnr	   Ú
isinstancer8   rD   )r4   ÚcolorÚcolormapÚ
valid_keysÚkeyr-   r-   r.   Ú_validate_color_argsv   s$   
ý
ÿÿÿzBoxPlot._validate_color_argsc                 C  s   t d| jd d�S )Né   )Ú
num_colorsrn   rm   )r   rn   r3   r-   r-   r.   Ú_color_attrs‹   s   zBoxPlot._color_attrsc                 C  ó
   | j d S ©Nr   ©rt   r3   r-   r-   r.   Ú_boxes_c“   ó   
zBoxPlot._boxes_cc                 C  ru   rv   rw   r3   r-   r-   r.   Ú_whiskers_c—   ry   zBoxPlot._whiskers_cc                 C  ru   )NrM   rw   r3   r-   r-   r.   Ú
_medians_c›   ry   zBoxPlot._medians_cc                 C  ru   rv   rw   r3   r-   r-   r.   Ú_caps_cŸ   ry   zBoxPlot._caps_crm   Ú
color_kwdsúQdict[str, MatplotlibColor] | MatplotlibColor | Collection[MatplotlibColor] | Nonec                 C  ó   d S ©Nr-   )r4   rs   r}   r-   r-   r.   Ú_get_colors£   s   zBoxPlot._get_colorsc                 C  s¤   t | jtƒr'| j d| j¡}| j d| j¡}| j d| j¡}| j d| j¡}n| jp,| j}| jp2| j}| jp8| j}| jp>| j}||||f}t|fd|i| j	¤Ž d S )Nrc   rd   re   rf   Ú	color_tup)
rl   rm   r8   Úgetrx   rz   r{   r|   Úmaybe_color_bpr]   )r4   r_   rc   rd   re   rf   r‚   r-   r-   r.   r„   ­   s   zBoxPlot.maybe_color_bpÚfigr   c                 C  sŠ  | j r{tjtd�| _| jd urt| j| jƒn| j}t	| j
|d�ƒD ]W\}\}}|  |¡}| j ¡ }| jd urO|j}| t|ƒ¡ | jjj}dd„ |d D ƒ}	nt|ƒg}	| j||f|| jdœ|¤Ž\}
}|  |¡ |
| j|< t||	| jdkd� q!d S | jjj}|  d¡}| j ¡ }| j||fd| jdœ|¤Ž\}
}|  |¡ |
| _d	d„ | jjD ƒ}| js¹d
d„ tt|ƒƒD ƒ}t||| jdkd� d S )N©Údtype)rJ   c                 S  rN   r-   r   )rP   Úcolr-   r-   r.   rR   Ú   rS   z&BoxPlot._make_plot.<locals>.<listcomp>r   )r\   r@   rB   )r   r   r   c                 S  rN   r-   r   )rP   Úleftr-   r-   r.   rR   ñ   rS   c                 S  rN   r-   r   )rP   rp   r-   r-   r.   rR   ó   rS   )rF   ÚpdÚSeriesÚobjectÚ_return_objÚbyr   rJ   r5   Ú	enumerateÚ
_iter_dataÚ_get_axr]   ÚcopyÚTÚ	set_titler   ÚcolumnsÚlevelsr`   r@   r„   r/   rG   ÚvaluesÚ	use_indexÚranger%   )r4   r…   rJ   r+   ÚlabelrK   r   r]   r–   Ú
ticklabelsÚretr_   r   r-   r-   r.   Ú
_make_plot¾   s\   
ÿý	




ÿÿ
ÿ

ÿé


ÿÿ
ÿ

ÿzBoxPlot._make_plotc                 C  r   r€   r-   r3   r-   r-   r.   Ú_make_legendø   s   zBoxPlot._make_legendc                 C  s4   | j r| t| j ƒ¡ | jr| t| jƒ¡ d S d S r€   )ÚxlabelÚ
set_xlabelr   ÚylabelÚ
set_ylabel)r4   r   rJ   r-   r-   r.   Ú_post_plot_logicû   s
   ÿzBoxPlot._post_plot_logicú!Literal['horizontal', 'vertical']c                 C  s   | j  dd¡r	dS dS )NÚvertTrB   r6   )r]   rƒ   r3   r-   r-   r.   rG     s   zBoxPlot.orientationc                   s   | j d u r	tƒ jS | jS r€   )r@   ÚsuperÚresultr�   r3   ©Ú	__class__r-   r.   r§   	  s   
zBoxPlot.result)r!   r1   )r7   )r@   rA   r!   r"   )Nr7   )r   r   rK   rL   r@   rA   )Nrm   )r}   r~   r!   r"   ©r!   r"   )r…   r   r!   r"   )r   r   r!   r"   )r!   r¤   )r;   r<   r=   Úpropertyr5   Ú_layout_typerC   r   r?   rE   Úclassmethodr`   rq   r   rt   rx   rz   r{   r|   r�   r„   r�   rž   r£   rG   r§   Ú__classcell__r-   r-   r¨   r.   r0   A   s@    ÿ




ú



:
r0   c                 K  sˆ   |  d¡st| d |d dd� |  d¡s t| d |d dd� |  d¡s0t| d	 |d
 dd� |  d¡sBt| d |d dd� d S d S )NÚboxpropsrc   r   é   )rm   ÚalphaÚwhiskerpropsrd   Úmedianpropsre   rM   Úcappropsrf   rr   )rƒ   r   )r_   r‚   r]   r-   r-   r.   r„     s   



ÿr„   TFÚnumeric_onlyÚgridÚfigsizeútuple[float, float] | Nonec
                 K  sp  |j |dd�}|d u rt|ttfƒs|g}| ¡ j |¡}t|ƒ}t||
 	dd¡|
 	dd¡|||d�\}}t
|ƒ}|
 	dd ¡|
 	dd ¡}}|
 d	d¡rQ|pO|}n|pT|}g }t|ƒD ].\}}|| }|| }t|Ž \}}| |||f||d
œ|
¤Ž}| |¡ | |¡ | |¡ q[tj||dd�}|	d u r˜|}t|ƒdkr¢|d n|}| d|› �¡ t|dddddd� |S )NF)ÚobservedrH   TrI   )ÚnaxesrH   rI   r·   r   ÚlayoutrŸ   r¡   r¥   )rŸ   r¡   )Úindexr’   r°   r   zBoxplot grouped by ç333333Ã?çÍÌÌÌÌÌì?çš™™™™™¹?çš™™™™™É?©ÚbottomÚtopr‰   ÚrightÚwspace)Úgroupbyrl   ÚlistÚtupleÚ_get_numeric_datar•   Ú
differencer%   r   Úpopr   rƒ   r�   Úzipr”   Úappendr¶   rŠ   r‹   Úsuptitler   )ÚplotfrJ   r•   rŽ   rµ   r¶   r·   r   r»   r@   r)   Úgroupedrº   r…   r7   Ú_axesrŸ   r¡   Ú	ax_valuesr+   rˆ   Úgp_colÚkeysr—   Úre_plotfr§   Úbyliner-   r-   r.   Ú_grouped_plot_by_column  sF   


ú	


r×   Úfontsizeú
int | NoneÚrotÚintc
              
     s|  dd l m} ˆtjvrtdƒ‚t| tƒr|  d¡} d}‡fdd„}d‡ ‡‡‡fdd	„}|ƒ ‰ |d u r5d }nt|tt	fƒr?|}n|g}|d urYt
|| f||||||ˆd
œˆ¤Ž}|S ˆd u r_d‰|d urgtdƒ‚|d u rŽ|d ursd|ini }| |¡� | ¡ }W d   ƒ n1 s‰w   Y  |  ¡ } t| jƒ}|dkrŸtdƒ‚|d u r§| j}n| | } ||| jj|fi ˆ¤Ž}| |¡ |S )Nr   z,return_type must be {'axes', 'dict', 'both'}Úxc                    s¤   t dd�} t | g d¢¡} t | d¡} ˆ  dd ¡}|rPt|ƒrKg d¢}tt|tdƒƒƒ}| 	¡ D ]\}}||v r?|| || < q0t
d|› d	|› �ƒ‚| S |  |¡ | S )
Nrr   )rs   )r   r   rM   Úkrm   rb   é   rg   rh   )r   rU   ÚtakerÍ   rË   r
   r8   rÌ   r™   ÚitemsrD   Úfill)r§   Úcolorsro   Úkey_to_indexrp   Úvalue)r]   r-   r.   r�   r  s&   
ÿÿ
þzboxplot.<locals>._get_colorsr   r   c                   sÔ   |  dd ¡|  dd ¡}}|r| t|ƒ¡ |r| t|ƒ¡ dd„ | D ƒ} dd„ |D ƒ}|j|fi |¤Ž}ˆd urA|jdˆd� t|| | dd	¡ˆd
� t|fdˆ i|¤Ž ˆdkr]|S ˆdkrht	j
||d�S |S )NrŸ   r¡   c                 S  rN   r-   r   )rP   rÜ   r-   r-   r.   rR   —  rS   z/boxplot.<locals>.plot_group.<locals>.<listcomp>c                 S  s   g | ]}t jt|ƒtd �‘qS )r†   )rU   Úasarrayr   rŒ   rO   r-   r-   r.   rR   ˜  s    r9   )ÚaxisÚ	labelsizer¥   T)r   r   r   Úrotationr‚   r8   rX   )rË   r    r   r¢   rZ   Útick_paramsr/   rƒ   r„   r0   r?   )rÔ   r—   r   r]   rŸ   r¡   r_   )râ   rØ   r@   rÚ   r-   r.   Ú
plot_group�  s&   ÿzboxplot.<locals>.plot_group)r•   rŽ   r¶   r·   r   r»   r@   r7   z7The 'layout' keyword is not supported when 'by' is Nonezfigure.figsizez;boxplot method requires numerical columns, nothing to plot.)r   r   )Úmatplotlib.pyplotÚpyplotr0   rC   rD   rl   r   Úto_framerÇ   rÈ   r×   Ú
rc_contextÚgcarÉ   r%   r•   r—   r“   r¶   )rJ   ÚcolumnrŽ   r   rØ   rÚ   r¶   r·   r»   r@   r]   Úpltr�   rê   r•   r§   Úrcrº   r-   )râ   rØ   r]   r@   rÚ   r.   rZ   [  sf   


þ÷
ö$é
ÿ
ÿ
rZ   c
                 K  s<   dd l m} t| f|||||||||	dœ	|
¤Ž}| ¡  |S )Nr   )	rð   rŽ   r   rØ   r¶   rÚ   r·   r»   r@   )rë   rì   rZ   Údraw_if_interactive)r4   rð   rŽ   r   rØ   rÚ   r¶   r·   r»   r@   r]   rñ   r-   r-   r.   Úboxplot_frameÝ  s$   ÿöõrô   rF   rH   rI   c              
   K  sF  |du rQt | ƒ}t|d||	|
||d�\}}t|ƒ}tjtd�}t| |ƒD ] \\}}}|jd|||||dœ|¤Ž}| t	|ƒ¡ ||j
|< q$t|ddddd	d
� |S t| Ž \}}| jdkretj||dd�}nt |ƒdkrw|d  |dd … ¡}n|d }|d ur‘t |¡}tj ||g¡}t|jƒ}|jd|||||||dœ|¤Ž}|S )NTF)rº   Úsqueezer   rH   rI   r·   r»   r†   )r   rð   rØ   rÚ   r¶   r½   r¾   r¿   rÀ   rÁ   r   r°   )rÔ   ræ   )rð   rØ   rÚ   r¶   r   r·   r»   r-   )r%   r   r   rŠ   r‹   rŒ   rÌ   rZ   r”   r   Úlocr   ræ   ÚconcatÚjoinÚcomÚconvert_to_list_likeÚ
MultiIndexÚfrom_productrÇ   r—   )rÐ   rF   rð   rØ   rÚ   r¶   r   r·   r»   rH   rI   r]   rº   r…   r7   rœ   rp   ÚgroupÚdrÔ   ÚframesÚdfÚ	multi_keyr-   r-   r.   Úboxplot_frame_groupbyý  sZ   
ù	
ÿÿæ


ùø
r  )r   r   r   r   r   r    r!   r"   rª   )NNTFNNNN)rµ   r    r¶   r    r·   r¸   )	NNNNr   TNNN)rØ   rÙ   rÚ   rÛ   r¶   r    r·   r¸   )
TNNr   TNNNFT)rF   r    rØ   rÙ   rÚ   rÛ   r¶   r    r·   r¸   rH   r    rI   r    );Ú
__future__r   Útypingr   r   r   rj   Úmatplotlib.artistr   ÚnumpyrU   Úpandas._libsr   Úpandas.util._decoratorsr   Úpandas.util._exceptionsr	   Úpandas.core.dtypes.commonr
   Úpandas.core.dtypes.genericr   Úpandas.core.dtypes.missingr   ÚpandasrŠ   Úpandas.core.commonÚcoreÚcommonrù   Úpandas.io.formats.printingr   Ú pandas.plotting._matplotlib.corer   r   Ú#pandas.plotting._matplotlib.groupbyr   Ú!pandas.plotting._matplotlib.styler   Ú!pandas.plotting._matplotlib.toolsr   r   r   Úcollections.abcr   Úmatplotlib.axesr   Úmatplotlib.figurer   Úmatplotlib.linesr   Úpandas._typingr   r/   r0   r„   r×   rZ   rô   r  r-   r-   r-   r.   Ú<module>   sŠ    
 
Qö?ö ö"õ