
    .iF                       d dl mZ d dlmZmZmZ d dlZd dl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c m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' d dl(m)Z)m*Z*m+Z+ erd dl,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl4m5Z5 ddZ6 G d de"      Z7ddZ8	 	 	 	 	 	 	 	 d	 	 	 	 	 d dZ9	 	 	 	 	 	 	 	 	 d!	 	 	 	 	 	 	 d"dZ:	 	 	 	 	 	 	 	 	 d!	 	 	 	 	 	 	 d"dZ;	 	 	 	 	 	 	 	 	 	 d#	 	 	 	 	 	 	 	 	 	 	 	 	 d$dZ<y)%    )annotations)TYPE_CHECKINGLiteral
NamedTupleN)lib)cache_readonly)find_stack_level)is_dict_like)	ABCSeries)remove_na_arraylike)Version)pprint_thing)LinePlotMPLPlot)create_iter_data_given_by)get_standard_colors)create_subplotsflatten_axesmaybe_adjust_figure)
Collection)Axes)Figure)Line2D)MatplotlibColorc                v   |r| j                         n| j                         }t        |      t        |      k7  rWt        t        |      t        |            \  }}t	        t
        j                        t	        d      k  r|dk(  sJ |       ||z  }|r | j                  |fi | y | j                  |fi | y)zSet 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.
    z3.10r   N)	
get_xticks
get_ytickslendivmodr   mpl__version__set_xticklabelsset_yticklabels)axlabelsis_verticalkwargsticksi	remainders          a/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/plotting/_matplotlib/boxplot.py_set_ticklabelsr,   0   s      +BMMOE
5zS[ c%j#f+693??#gfo5>,9,>!6,V,6,V,    c                      e Zd Zedd       ZdZdZ G d de      ZdddZ	e
	 d	 	 	 	 	 dd       Zd Zed	        Zed
        Zed        Zed        Zed        Z	 	 d	 	 	 ddZddZddZddZddZedd       Ze fd       Z xZS ) BoxPlotc                     y)Nbox selfs    r+   _kindzBoxPlot._kindD   s    r-   
horizontal)Naxesdictbothc                  "    e Zd ZU ded<   ded<   y)
BoxPlot.BPr   r$   zdict[str, list[Line2D]]linesN)__name__
__module____qualname____annotations__r2   r-   r+   BPr;   L   s    &&r-   rA   c                    || j                   vrt        d      || _        t        j                  | |fi | | j
                  r| j                  dk(  rd| _        y d| _        y y )Nz2return_type must be {None, 'axes', 'dict', 'both'}verticalF)	_valid_return_types
ValueErrorreturn_typer   __init__subplotsorientationsharexsharey)r4   datarF   r'   s       r+   rG   zBoxPlot.__init__Q   sc    d666QRR&t.v.== :-## r-   c                t   |j                   dk(  r[|D cg c]  }t        |       }}|D cg c]7  }|j                  dkD  r|n#t        j                  t        j
                  g      9 }}nt        |      } |j                  |fi |}|dk(  r||fS |dk(  r| j                  ||      |fS ||fS c c}w c c}w )N   r   r8   r9   r$   r<   )ndimr   sizenparraynanboxplotrA   )	clsr$   y
column_numrF   kwdsvysbps	            r+   _plotzBoxPlot._plotb   s    
 66Q;234Q%a(4B4 DFFaqvvz!rxx'99FBF$Q'BRZZ#d#& r6MF"66Rr6*B..r6M 5 Gs
   B0<B5c                    |t         j                  u ry |t        j                  dt	                      t        |t              r g d}|D ]  }||vst        d| d|        |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   rE   )r4   colorcolormap
valid_keyskeys        r+   _validate_color_argszBoxPlot._validate_color_argsx   s    CNN"MMU+-
 eT"AJ j($;C5 A22<?  r-   c                2    t        d| j                  d       S )N   )
num_colorsrl   rk   )r   rl   r3   s    r+   _color_attrszBoxPlot._color_attrs   s     #a$--tTTr-   c                     | j                   d   S Nr   rs   r3   s    r+   _boxes_czBoxPlot._boxes_c         ##r-   c                     | j                   d   S ru   rv   r3   s    r+   _whiskers_czBoxPlot._whiskers_c   rx   r-   c                     | j                   d   S )NrN   rv   r3   s    r+   
_medians_czBoxPlot._medians_c   rx   r-   c                     | j                   d   S ru   rv   r3   s    r+   _caps_czBoxPlot._caps_c   rx   r-   c                     y Nr2   )r4   rr   
color_kwdss      r+   _get_colorszBoxPlot._get_colors   s     	r-   c                v   t        | j                  t              r| j                  j                  d| j                        }| j                  j                  d| j
                        }| j                  j                  d| j                        }| j                  j                  d| j                        }nh| j                  xs | j                  }| j                  xs | j
                  }| j                  xs | j                  }| j                  xs | j                  }||||f}t        |fd|i| j                   y )Nra   rb   rc   rd   	color_tup)
rj   rk   r8   getrw   rz   r|   r~   maybe_color_bprY   )r4   r\   ra   rb   rc   rd   r   s          r+   r   zBoxPlot.maybe_color_bp   s    djj$'JJNN7DMM:Ezz~~j$2B2BCHjjnnY@G::>>&$,,7D JJ/$--Ezz5T%5%5Hjj3DOOG::-DHgt4	r<Y<$))<r-   c                ~   | j                   rg }g }| j                   t        | j                  | j                        n| j                  }t        | j                  |            D ]   \  }\  }}| j                  |      }| j                  j                         }	| j                  b|j                  }|j                  t        |             | j                  j                  j                  }
|
d   D cg c]  }t        |       }}nt        |      g} | j                  ||f|| j                   d|	\  }}| j#                  |       |j%                  |       |j%                  |       t'        ||| j(                  dk(         # t+        j,                  ||t.              | _        y | j                  j2                  j                  }| j                  d      }| j                  j                         }	 | j                  ||fd| j                   d|	\  }}| j#                  |       || _        | j                  j                  D cg c]  }t        |       }}| j4                  s*t7        t9        |            D cg c]  }t        |       }}t'        ||| j(                  dk(         y c c}w c c}w c c}w )N)rL   r   )rX   rF   rC   )r$   r%   r&   )indexdtype)rH   byr   rL   r5   	enumerate
_iter_data_get_axrY   copyT	set_titler   columnslevelsr]   rF   r   appendr,   rI   pdSeriesobject_return_objvalues	use_indexranger   )r4   figobj_axes
obj_labelsrL   r)   labelrW   r$   rY   r   col
ticklabelsretr\   leftr%   rn   s                     r+   
_make_plotzBoxPlot._make_plot   se   ==HJ
 77& *$))TZZ@YY  "+4???+E!F :E1\\!_yy~~' 77&ALLe!45
 "YY..55F?Eay!I,s"3!IJ!I".u"5!6J$$**&'T5E5EIMR ##B'$!!%(*$:J:Jj:X16  "yy6RD		  ""AaB99>>#D djjA"#1A1AEIGC #"D59YY5F5FGTl4(GFG>>7<S[7IJ,s+JJf$2B2Bj2P9 "J2 HJs   3J0
J5 J:c                     y r   r2   r3   s    r+   _make_legendzBoxPlot._make_legend   s    r-   c                    | j                   r$|j                  t        | j                                | j                  r%|j	                  t        | j                               y y r   )xlabel
set_xlabelr   ylabel
set_ylabel)r4   r$   rL   s      r+   _post_plot_logiczBoxPlot._post_plot_logic   s?    ;;MM,t{{34;;MM,t{{34 r-   c                >    | j                   j                  dd      ryy)NvertTrC   r6   )rY   r   r3   s    r+   rI   zBoxPlot.orientation  s    99==&r-   c                H    | j                   
t        |   S | j                  S r   )rF   superresultr   )r4   	__class__s    r+   r   zBoxPlot.result
  s%    #7>!###r-   )returnzLiteral['box'])r7   )rF   strr   None)Nr7   )r$   r   rW   z
np.ndarrayrF   r   )Nrk   )r   zQdict[str, MatplotlibColor] | MatplotlibColor | Collection[MatplotlibColor] | Noner   r   r   r   )r   r   r   r   )r$   r   r   r   )r   z!Literal['horizontal', 'vertical'])r=   r>   r?   propertyr5   _layout_typerD   r   rA   rG   classmethodr]   ro   r   rs   rw   rz   r|   r~   r   r   r   r   r   rI   r   __classcell__)r   s   @r+   r/   r/   C   s-      L8'Z '
$" JP$DG *( U U $ $ $ $ $ $ $ $
   
="8t5     $ $r-   r/   c                   |j                  d      s(t        j                  j                  | d   |d   d       |j                  d      s(t        j                  j                  | d   |d   d       |j                  d      s(t        j                  j                  | d	   |d
   d       |j                  d      s)t        j                  j                  | d   |d   d       y y )Nboxpropsra   r      )rk   alphawhiskerpropsrb   medianpropsrc   rN   cappropsrd   rq   )r   r    artistsetp)r\   r   rY   s      r+   r   r     s     88J

79Q<qA88N#

:il!D88M"

9Yq\C88J

6
)A,a@  r-   c
                N   |j                  |d      }|Bt        |t        t        f      s|g}|j	                         j
                  j                  |      }t        |      }t        ||
j                  dd      |
j                  dd      |||      \  }}|
j                  dd       |
j                  dd       }}|
j                  d	d      r|xs |}n|xs |}g }t        t        |      |d
      D ]Y  \  }}||   }t        |ddi\  }} | |||f||d|
}|j                  |       |j                  |       |j                  |       [ t!        j"                  ||d      }|	|}t        |      dk(  r|d   n|}|j%                  d|        t'        |ddddd       |S )NF)observedrJ   TrK   )naxesrJ   rK   figsizer$   layoutr   r   r   strictr   )r   r   )r   r   r   r   zBoxplot grouped by 333333??皙?皙?bottomtopr   rightwspace)groupbyrj   listtuple_get_numeric_datar   
differencer   r   popr   zipr   r   r   gridr   r   suptitler   )plotfrL   r   r   numeric_onlyr   r   r$   r   rF   r'   groupedr   r   r7   r   r   	ax_valuesr   gp_colkeysr   re_plotfr   bylines                            r+   _grouped_plot_by_columnr     s    ll2l.G"tUm,B((*22==bALEzz(D)zz(D)IC ZZ$/Hd1KFFzz&$22I|D)75A CF040fvrR&R6R
S"
 YYye<F "glRUFLL&vh/0Dc3sSMr-   c
                  	
 dd l m} 	t        j                  vrt	        d      t        | t              r| j                  d      } d}
fd}d	fd} |       |d }nt        |t        t        f      r|}n|g}|t        || f||||||	d
}|S 	d	|t	        d      |6|d	|ini }t        j                  |      5  |j                         }d d d        | j                         } t        | j                         }|dk(  rt	        d
      || j                   }n| |   }  ||| j"                  j$                  |fi 
}|j'                  |       |S # 1 sw Y   xY w)Nr   z,return_type must be {'axes', 'dict', 'both'}xc                    t        d      } t        j                  | g d      }t        j                  |d      }j	                  dd       }|rwt        |      r[g d}t        t        |t        d      d	            }|j                         D ]"  \  }}||v r	||||   <   t        d
| d|        |S |j                  |       |S )Nrq   )rr   )r   r   rN   krk   r`      Tr   re   rf   )r   rR   taker   r   r
   r8   r   r   itemsrE   fill)result_listr   colorsrm   key_to_indexrn   valuerY   s          r+   r   zboxplot.<locals>._get_colorsp  s     *Q7i063''4(F# F
#C
E!HT$JK"(,,. JCj(49|C01(?u E66@\C 	  F#r-   c                $   |j                  dd       |j                  dd       }}|r|j                  t        |             |r|j                  t        |             | D cg c]  }t        |       } }|D cg c]  }t	        |       }} |j
                  |fi |}
|j                  d
       t        || |j                  dd             t        |fd	i| d	k(  r|S dk(  rt        j                  ||
      S |S c c}w c c}w )Nr   r   r9   )axis	labelsizer   T)r$   r%   r&   rotationr   r8   rO   )r   r   r   r   r   rU   tick_paramsr,   r   r   r/   rA   )r   r   r$   rY   r   r   r   rZ   r\   r   fontsizerF   rots            r+   
plot_groupzboxplot.<locals>.plot_group  s   (D1488Hd3KMM,v./MM,v./)-.AQ..289Q%a(99RZZ'$'NN(N; 	$DHHVT,BS	
 	r4V4t4 & IF"::2:..I% /9s   "D:D)r   r   r   r   r$   r   rF   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pyplotr/   rD   rE   rj   r   to_framer   r   r   r    
rc_contextgcar   r   r   r   r   r   )rL   columnr   r$   r   r   r   r   r   rF   rY   pltr   r   r   r   rcr   r   s       ``   ``       @r+   rU   rU   Y  s    $ '555GHH$	"}}S!: 8 ]F~	FT5M	*(	~ )
 #
 
H M/  KVWW:070C"G,B# WWY%%'DLL!A:M  ?llG=DGT[[]]B?$?
M! s   EE(c
                ^    dd l m} t        | f|||||||||	d	|
}|j                          |S )Nr   )	r   r   r$   r   r   r   r   r   rF   )r   r   rU   draw_if_interactive)r4   r   r   r$   r   r   r   r   r   rF   rY   r   s               r+   boxplot_framer    sQ     $	

 
B Ir-   c                n   |du rt        |       }t        |d||	|
||      \  }}i }t        | t        |      d      D ]?  \  \  }}} |j                  d|||||d|}|j                  t        |             |||<   A t        j                  |      }t        |ddddd	
       |S t        | ddi\  }}t        j                  ||d      }|Kt        j                  |      }t        j                  j                  ||g      }t        |j                         } |j                  d|||||||d|}|S )NTF)r   squeezer$   rJ   rK   r   r   r   )r$   r   r   r   r   r   r   r   r   r   r   r   )r   r   )r   r   r   r   r$   r   r   r2   )r   r   r   r   rU   r   r   r   r   r   concatcomconvert_to_list_like
MultiIndexfrom_productr   r   )r   rH   r   r   r   r   r$   r   r   rJ   rK   rY   r   r   r7   rL   rn   groupdr   r   framesdf	multi_keys                           r+   boxplot_frame_groupbyr    st    4G#
	T  #G\$-? N 	LS%" fxStOSA LLc*+DI	 iioC#CsSVW. J+ G1D1fYYvDq1 --f5F22D&>BI)**+Fbjj 	
	
 	
 Jr-   )r$   r   r%   z	list[str]r&   boolr   r   r   )NNTFNNNN)r   r  r   r  r   tuple[float, float] | None)	NNNNr   TNNN)r   
int | Noner   intr   r  r   r  )
TNNr   TNNNFT)rH   r  r   r  r   r  r   r  r   r  rJ   r  rK   r  )=
__future__r   typingr   r   r   rh   
matplotlibr    numpyrR   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.util.versionr   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,   r/   r   r   rU   r  r  r2   r-   r+   <module>r.     s   " 
     2 4 2 0 :      ' 3 J A  *$('.-&L$h L$^
A  *.7
 7 7 (7x *.
  
  (H *.
  
  (D *.88 	8
 
8 8 (8 8 8r-   