
     j                      d dl mZ d dlmZmZ d dlmZmZmZm	Z	 d dl
mZmZ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mZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z*m+Z+ d dl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 d dl3m4Z4 d dl5m6c m7Z8 d dl9m:Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@ d dlAmBZB d dlCmDZD d dlEmFZF d dlGmHZH d dlImJZJmKZKmLZLmMZMmNZN d dlOmPZPmQZQmRZRmSZSmTZTmUZU er*d dlVmWZW d dlXmYZY d dlZm[Z[ d dl\m]Z] d dl^m_Z_m`Z`maZambZb d dlcmdZd d5d"Ze G d# d$e          Zf G d% d&efe          Zg G d' d(eg          Zh G d) d*eg          Zi G d+ d,ef          Zj G d- d.ej          Zk G d/ d0ef          Zl G d1 d2el          Zm G d3 d4ef          ZndS )6    )annotations)ABCabstractmethod)HashableIterableIteratorSequence)TYPE_CHECKINGAnyLiteralcastfinalN)libAbstractMethodError)cache_readonly)find_stack_level)is_any_real_numeric_dtypeis_boolis_floatis_float_dtypeis_hashable
is_integeris_integer_dtypeis_iteratoris_list_like	is_numberis_numeric_dtype)CategoricalDtypeExtensionDtype)ABCDataFrameABCDatetimeIndexABCIndexABCMultiIndexABCPeriodIndex	ABCSeries)isna)	DataFrame)Versionpprint_thing)tools)%register_pandas_matplotlib_converters)reconstruct_data_with_by)unpack_single_str_list)get_standard_colors)decorate_axesformat_dateaxismaybe_convert_indexmaybe_resampleuse_dynamic_x)create_subplotsflatten_axesformat_date_labelsget_all_linesget_xlimhandle_shared_axes)ArtistAxes)Axis)Figure)
IndexLabelNDFrameTPlottingOrientationnpt)Seriesstylestrreturnboolc                T    ddl m} t          |                              |            S )z?
    Check if there is a color letter in the style string.
    r   )BASE_COLORS)matplotlib.colorsrK   set
isdisjoint)rF   rK   s     tC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pandas/plotting/_matplotlib/core.py_color_in_stylerP   c   s5     .-----;**51111    c            	         e Zd ZU dZeedd                        ZdZdZedd            Z	d	e
d
<   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddddddddddd.Zeedd/                        Zedd2            Zeedd6                        Zd7 Zeedd:                        Zdd<Zeedd=                        Zedd>            Zedd?            ZeeddB                        ZeddD            ZeeddF                        ZeeddH                        ZeeddJ                        ZedK             ZeedL                         ZeddM            Z eddN            Z!ddPZ"eddQ            Z#eddR            Z$eddS            Z%eddT            Z&ee	 dddW                        Z'eeddX                        Z(eddZ            Z)edd]            Z*dd^Z+eedd_                        Z,eed`                         Z-dZ.eda             Z/ee0	 ddde                        Z1df Z2eddg            Z3eedddi                        Z4eddk            Z5eddm            Z6eddn            Z7eddr            Z8	 	 dddvZ9eeddz                        Z:e	 ddd}            Z;edd~            Z<edd            Z=dS )MPLPlotzm
    Base class for assembling a pandas plot using matplotlib

    Parameters
    ----------
    data :

    rH   rG   c                    t           )z3Specify kind str. Must be overridden in child class)NotImplementedErrorselfs    rO   _kindzMPLPlot._kindv   s
     "!rQ   verticalr   
str | Nonec                    d S N rV   s    rO   orientationzMPLPlot.orientation       trQ   r(   dataNFT)logxlogyloglog
mark_rightstackedlabelrF   byIndexLabel | Nonesubplotsbool | Sequence[Sequence[str]]sharexbool | NoneshareyrI   	use_indexfigsizetuple[float, float] | Nonelegend
bool | strxlabelHashable | Noneylabelfontsize
int | Nonesecondary_y bool | tuple | list | np.ndarraytableinclude_boolcolumnra   bool | None | Literal['sym']rb   rc   rd   re   rf   Nonec               6    dd l m}$ |g dfv rt          d          t          j        |           _        t          t                    rU|rt          j        |           _        n9 j        fdj        D              _        n fdj        D              _         j        7 j	        dk    r,
                    t           j                             _        | _        t                                         | j	                   _        t                                         |||           _        | _        | _        | _        | _        | _        | _        | _        | _        | _        | _        | _        | _        || _        d _         nd	 _          j!         _        |	|rd	n|$j"        d
         }	|	 _#        |
 _$        g  _%        g  _&        t                     '                    d|           _(        t                     '                    d|           _)        t                     '                    d|           _*        |! _+        |" _,        | _-        |  _.        | _/        |#0                    dd           }%|#0                    dd           }& 1                              }'t                     2                    d|%|'          \  }%t                     2                    d|&|'          \  }&|%|&d _3         _4        t          |tj          tl          tn          tp          j9        tt          f          s|g}| _;        d|#v r|rty          d          d|#v r|#0                    d           _=        n| _=        | _>        | _?        |# _@        |#0                    dt          jB                  }( C                    |( j=                   _D        d j@        vsJ  E                     j4                   _4        d S )Nr   r]   zNo group keys passed!c                >    g | ]}t          |                   |S r]   )r   ).0colr`   s     rO   
<listcomp>z$MPLPlot.__init__.<locals>.<listcomp>   s;          3CDI3N3N      rQ   c                P    g | ]"}|j         vt          |                    |#S r]   )rg   r   )r   r   r`   rW   s     rO   r   z$MPLPlot.__init__.<locals>.<listcomp>   sL          $')  /?tCy.I.I      rQ   hist)kindTFz	axes.gridra   rb   rc   xerryerr)r   r   cmapz*Only specify one of `cmap` and `colormap`.color)Fmatplotlib.pyplotpyplot
ValueErrorcommaybe_make_listrg   
isinstancer(   columnsrX   groupbyr/   _groupedr   type_validate_subplots_kwargri   _validate_sharexrk   rm   ro   layoutxticksyticksxlimylimtitlern   rs   ru   rv   rot_rot_set_default_rotrcParamsgridrq   legend_handleslegend_labels_validate_log_kwdra   rb   rc   rf   rF   rd   re   axpop_get_nseries_parse_errorbarserrorsr`   rI   tuplelistnpndarrayr#   rx   	TypeErrorcolormaprz   r{   kwdsr   
no_default_validate_color_argsr   _ensure_frame))rW   r`   r   rg   ri   rk   rm   rn   ro   r   rq   r   r   figr   r   r   r   r   rs   ru   rv   rx   r   rz   r   r{   r|   ra   rb   rc   rd   re   rf   rF   r   pltr   r   nseriesr   s)   ``                                       rO   __init__zMPLPlot.__init__   s.   N 	(''''' "b> 	64555%b))
 dI&& 	 "26:: 	       #'<              #|      7 	J4:#7 	J LL)?)H)HIIDM	T

;;d < 
 
 4jj11&"bAA		
"  	)DH !DMM!DM(DH 	G'F55S\+-FD	,.-/JJ00>>	JJ00>>	4jj228VDD

$ 
 xx%%xx%%##D))$ZZ00tWMM
d$ZZ00tWMM
d#T22	+eT2:x'PQQ 	(&-K& T> 	Jh 	JHIIIT> 	% HHV,,DMM$DM
(	#.11..udmDD
di''''&&ty11			rQ   c                t    | 
||d} n!d} nt          |           st          d          t          |           S )NTFzsharex must be a bool or None)r   r   rI   )rk   r   rg   s      rO   r   zMPLPlot._validate_sharex   sT      		= b   	=;<<<F||rQ   kwdvaluec                    |0t          |t                    st          |t                    r|dk    r|S t          d| d| d          )Nsymz	keyword 'z'' should be bool, None, or 'sym', not '')r   rI   rG   r   )clsr   r   s      rO   r   zMPLPlot._validate_log_kwd/  so     	%&&	 5#&&	 ,1E>	
 LLLLELLL
 
 	
rQ   Series | DataFramer   bool | list[tuple[int, ...]]c                |   t          | t                    r| S t          | t                    st          d          d}||vr)t          dd                    |           d| d          t          |t
                    rt          d          |j        }t          |t                    rt          d          |	                                t          |          k    rt          d	          g }t                      }| D ]}t          |          st          d
          |                    |          }|dk                                    r9t          j        |dk    |          }	t          dt#          |	           d          t          |          }
|                    |
          }|rt          d| d          |                    |
          }|                    t+          |                     |                    |          }|D ]-}|                    |          }|                    |f           .|S )a_  
        Validate the subplots parameter

        - check type and content
        - check for duplicate columns
        - check for invalid column names
        - convert column names into indices
        - add missing columns in a group of their own
        See comments in code below for more details.

        Parameters
        ----------
        subplots : subplots parameters as passed to PlotAccessor

        Returns
        -------
        validated subplots : a bool or a list of tuples of column indices. Columns
        in the same tuple will be grouped together in the resulting plot.
        z(subplots should be a bool or an iterable)linebarbarhr   kdedensityareapiez2When subplots is an iterable, kind must be one of z, z. Got .z3An iterable subplots for a Series is not supported.zOAn iterable subplots for a DataFrame with a MultiIndex column is not supported.zTAn iterable subplots for a DataFrame with non-unique column labels is not supported.zPWhen subplots is an iterable, each entry should be a list/tuple of column names.zColumn label(s) z not found in the DataFrame.z3Each column should be in only one subplot. Columns z! were found in multiple subplots.)r   rI   r   r   joinr&   rU   r   r$   nuniquelenrM   r   get_indexer_foranyr   extractr   intersectionunionappendr   
differenceget_loc)ri   r`   r   supported_kindsr   outseen_columnsgroupidx_locs
bad_labelsunique_columns
duplicatesunseen_columnsr|   idx_locs                  rO   r   z MPLPlot._validate_subplots_kwarg?  s   2 h%% 	IOHh// 	IGHHH	
 & 	D))O44D D<@D D D  
 dI&& 	%E   ,g}-- 	%$  
 ??G, 	%+  $ &)ee 	( 	(E&&  >   ..u55HB##%% ZB>>
 UtJ'7'7UUU   !ZZN%22>BBJ  M)M M M   (--n==LJJuX'''' ++L99$ 	# 	#Foof--GJJz""""
rQ   c                
   |t           j        u r/d| j        v r$|"t          j        dt                                 d S | j        dk    r|t          |          s|g}t          |t                    r| j        dk    rt          |          dv r|g}|"t          j        dt                                 | j        Gt          | j                  r| j        }n| j        g}|D ] }t          |          rt          d          !|S )NcolorszC'color' and 'colormap' cannot be used simultaneously. Using 'color'
stacklevel   )      zCannot pass 'style' string with a color symbol and 'color' keyword argument. Please use one or the other or pass 'style' without a color symbol)r   r   r   warningswarnr   r   r   r   r   r   rF   rP   r   )rW   r   r   stylesss        rO   r   zMPLPlot._validate_color_args  sZ   CN" 	49$  $/11   
 4<1 	 	<;N;N 	GEeU## 	(9 	c%jjF>R 	GE 	MU+--   
 : 	DJ'' &*  "1%% $G   rQ   .DataFrame | dict[Hashable, Series | DataFrame]%Iterator[tuple[Hashable, np.ndarray]]c              #  x   K   |                                  D ]"\  }}|t          j        |j                  fV  #d S r\   )itemsr   asarrayvalues)r`   r   r   s      rO   
_iter_datazMPLPlot._iter_data  sO      
  ::<< 	1 	1KC rz&-0000000		1 	1rQ   intc                    |j         dk    rdS | j        | j        dk    rt          | j                  S | j        | j        dk    rt          | j                  S |j        d         S )Nr   r   box)ndimrg   rX   r   r   r   shaperW   r`   s     rO   r   zMPLPlot._get_nseries  ss     9> 	!1W 	!TZ6%9 	!t}%%%W 	!TZ5%8 	!t|$$$:a= rQ   c                6    |                      | j                  S r\   )r   r`   rV   s    rO   r   zMPLPlot.nseries  s       +++rQ   c                8    | j                                          d S r\   )r   draw_if_interactiverV   s    rO   drawzMPLPlot.draw  s    $$&&&&&rQ   c                T   |                                   | j        }|                     |           |                                  |                                  |                     |           | j        D ]2}|                     |           |                     || j	                   3d S r\   )
_compute_plot_datar   
_make_plot
_add_table_make_legend_adorn_subplotsaxes_post_plot_logic_common_post_plot_logicr`   )rW   r   r   s      rO   generatezMPLPlot.generate  s    !!!hS!!!) 	1 	1B((,,,!!"di0000	1 	1rQ   r   r>   c                    t          | j                  dk    p/t          | j                  dk    pt          | j                  dk    S )zcheck whether ax has datar   )r   linesartists
containers)r   s    rO   _has_plotted_objectzMPLPlot._has_plotted_object  s>     28}}!TS__%9TS=O=OST=TTrQ   axes_numc                D   |                      |          s|                     |          S t          |d          r|j        S t          |d          r|S ||                                }}|j        |_        |j        |_        ||c|_        |_        |                     |          s'|	                                
                    d           | j        du s	| j        du r|                    d           n+| j        dk    s| j        dk    r|                    d           |S )Nright_axleft_axFTlogr   symlog)on_right_get_ax_layerhasattrr  twinx
_get_lines_get_patches_for_fillr  r
  	get_yaxisset_visiblerb   rc   
set_yscale)rW   r   r  orig_axnew_axs        rO   _maybe_right_yaxiszMPLPlot._maybe_right_yaxis  sA   }}X&& 	*%%b)))2z"" 	;R## 	I !"((**VG ' 2F - (
  -Gfn
 ++G44 7!!##//666yD  ,DK4$7 ,!!%((((e# ,t{e'; ,!!(+++MrQ   r@   c                    | j         d         S Nr   _axes_and_figrV   s    rO   r   zMPLPlot.fig(  s     !!$$rQ   Sequence[Axes]c                    | j         d         S Nr   r  rV   s    rO   r  zMPLPlot.axes-  s     !!$$rQ   tuple[Sequence[Axes], Figure]c           	     F   | j         rmt          | j         t                    r| j        nt	          | j                   }t          || j        | j        | j        | j	        | j
        | j                  \  }}n~| j	        6| j                            | j                  }|                    d          }nA| j	                                        }| j        |                    | j                   | j	        }t#          |          }| j        du s	| j        du rd |D              n"| j        dk    s| j        dk    rd |D              | j        du s	| j        du rd |D              n"| j        dk    s| j        dk    rd	 |D              t+          t,          d
         |          }||fS )N)naxesrk   rm   ro   r   r   layout_type)ro   o   Tc                8    g | ]}|                     d           S r  
set_xscaler   as     rO   r   z)MPLPlot._axes_and_fig.<locals>.<listcomp>O  $    ///QQ\\%  ///rQ   r   c                8    g | ]}|                     d           S r  r+  r-  s     rO   r   z)MPLPlot._axes_and_fig.<locals>.<listcomp>Q  $    222Q\\(##222rQ   c                8    g | ]}|                     d           S r*  r  r-  s     rO   r   z)MPLPlot._axes_and_fig.<locals>.<listcomp>T  r/  rQ   c                8    g | ]}|                     d           S r1  r4  r-  s     rO   r   z)MPLPlot._axes_and_fig.<locals>.<listcomp>V  r2  rQ   r>   )ri   r   rI   r   r   r6   rk   rm   ro   r   r   _layout_typer   figureadd_subplot
get_figureset_size_inchesr7   ra   rc   rb   r   r	   )rW   r&  r   r  axes_seqs        rO   r   zMPLPlot._axes_and_fig3  s    = 	 *4=$ ? ?WSEWEW  ({{7{ -  IC W 	(//$,/77C??3''DD'$$&&C| 2##DL1117DD!!9 	3t 3 	3//$/////Y% 	34;%#7 	322T22229 	3t 3 	3//$/////Y% 	34;%#7 	322T2222($//}rQ   c                   | j         r6| j        (t          | j                  s | j        j        | j         S | j        S t          | j        t                    o| j        }t          | j                  ot          | j                  | j
        k    }|s|r"|                     | j        d         d          S | j        d         S )z$
        Return result axes
        Nr   F)primary)ri   r   r   r   r  reshaper   rx   rI   r   r   r  )rW   sec_trueall_secs      rO   resultzMPLPlot.result[  s    
 = 	${ !|DG/D/D !(ty($+66y !$"2D99Nd>NH T-.. :())T\9   $7 $))$)A,)FFFy|#rQ   c                R   t          | j        t                    r| S t          | j                  st	          | j                  r;t          | j        t
                    r!|                     dt          j                  S t          |           dk    rt          j
        |           S | S )Nfloat)dtypena_valuer   )r   rD  r   r   r   r    to_numpyr   nanr   r   r`   s    rO   _convert_to_ndarrayzMPLPlot._convert_to_ndarrayt  s     dj"233 	K TZ(( 	AN4:,F,F 	AJJM
 M
 	A ==w=@@@ t99q= 	$:d###rQ   c                   t          |t                    r@| j        }|	|j        d}||                                }nN|                    |          }n7| j        dv r.| j        | j        n| j        | j        z   }|j        d d |f         }|S )N )name)r   r   )	r   r&   rf   rL  to_framerX   rg   r   loc)rW   r`   rf   colss       rO   r   zMPLPlot._ensure_frame  s    dI&& 	%JE   1}}}}%}00Z?* 	%#'7N4<<tw8ND8AAAtG$DrQ   c                V   | j         }| j        (d| _        t          | j         | j        | j                  }|                    d          }t          j        dddg}| j        du r|	                    t          j
                   d }| j        dk    rt          j        g}dg}| j        d	k    r|                    g d
           |                    ||          }|j        d         dk    }|rt          d          |                    t#          |           j                  | _         d S )NT)rg   rO  F)copydatetime
datetimetz	timedeltar   scatter)objectcategorystring)includeexcluder   r   zno numeric data to plot)r`   rg   ri   r.   r   infer_objectsr   numberr{   r   bool_rX   extendselect_dtypesr   r   applyr   rI  )rW   r`   include_typeexclude_typenumeric_datais_emptys         rO   r   zMPLPlot._compute_plot_data  s=   y 7 	V DM+DI$'UUUD !!u!--	:|[I $ 	*))) : 	)I;L'=L :" 	B @ @ @AAA)),)UU%b)Q. 	75666 &&tDzz'EFF			rQ   r   c                     t          |           r\   r   )rW   r   s     rO   r   zMPLPlot._make_plot  s    !$'''rQ   c                    | j         du rd S | j         du r| j                                        }n| j         }|                     d          }t	          j         ||           d S )NFTr   )rz   r`   	transpose_get_axr,   )rW   r`   r   s      rO   r   zMPLPlot._add_table  sh    : 	FZ4 	9&&((DD:D\\!__BrQ   c                   | j         dk    s| j         t          |                               |j        | j        | j                   t          |                               |j        | j                   t          |d          r5t          |                               |j        j        | j                   dS dS | j         dk    rt          |                               |j        | j        | j                   t          |                               |j        | j                   t          |d          r5t          |                               |j        j        | j                   dS dS t          )z!Common post process for each axesrY   N)r   rv   )rv   r  
horizontal)
r^   r   _apply_axis_propertiesxaxisr   rv   yaxisr  r  r   )rW   r   s     rO   r  zMPLPlot._post_plot_logic_common  s    z) 	T-= 	JJ--dh .    JJ--bh-OOOr:&& T

11K% 2      
 - 	JJ--dh .    JJ--bh-OOOr:&& T

11K% 2      
 rQ   c                    dS )z7Post process for each axes. Overridden in child classesNr]   rW   r   r`   s      rO   r  zMPLPlot._post_plot_logic  s      rQ   c           	        t          | j                  dk    r]|                     |          }|                     |          \  }}t	          |t          |          ||z  ||| j        | j                   | j        D ]}t          |d|          }| j        |	                    | j                   | j
        |                    | j
                   | j        |                    | j                   | j        |                    | j                   | j        '|                    t%          | j                             |                    | j                   | j        r| j        rt-          | j                  rt          | j                  | j        k    r,t1          dt          | j                   d| j                   t3          | j        | j                  D ]\  }}|                    |           dS |                    | j                   dS t-          | j                  rd}t1          |          | j        d                             | j                   dS dS )z%Common post process unrelated to datar   )axarrnplotsr&  nrowsncolsrk   rm   r  Nz~The length of `title` must equal the number of columns if using `title` of type `list` and `subplots=True`.
length of title = z
number of columns = zNUsing `title` of type `list` is not supported unless `subplots=True` is passed)r   r  _get_subplots_get_axes_layoutr;   rk   rm   getattrr   
set_yticksr   
set_xticksr   set_ylimr   set_xlimru   
set_ylabelr+   r   r   ri   r   r   r   zip	set_titlesuptitle)rW   r   all_axesrs  rt  r   r   msgs           rO   r  zMPLPlot._adorn_subplots  s    ty>>A 	))#..H0055LE58}}em{{    ) 	 	BZ,,B{ +dk***{ +dk***y 'DI&&&y 'DI&&& { 9l4;77888GGDI: 	3} 3
++ -4:$,6 (B 25TZB B 48<	B B   &)DJ%?%? , ,	EU++++, , LL,,,,,
++ *;  %S//)	!&&tz22222/	3 	3rQ   axisr?   c                    ||\|                                  |                                 z   }|D ]2}||                    |           ||                    |           1dS dS )a  
        Tick creation within matplotlib is reasonably expensive and is
        internally deferred until accessed as Ticks are created/destroyed
        multiple times per draw. It's therefore beneficial for us to avoid
        accessing unless we will act on the Tick.
        N)get_majorticklabelsget_minorticklabelsset_rotationset_fontsize)r  r   rv   labelsrf   s        rO   rk  zMPLPlot._apply_axis_properties)  s      	1h 	1--//$2J2J2L2LLF 1 1 ,&&s+++ 1&&x000	1 	11 1rQ   c                    t          | j        j        t                    s$| j        j        j        }|t          |          }|S t          t
          | j        j        j                  }d                    |          S )N,)	r   r`   r   r$   rL  r+   mapnamesr   )rW   rL  stringifieds      rO   legend_titlezMPLPlot.legend_title=  sk     $)+];; 	)9$)D *#D))KlDI,=,CDDK88K(((rQ   indexc                V    | j         s!| j        r|                     |          r|dz  }|S )z
        Append ``(right)`` to the label of a line if it's plotted on the right axis.

        Note that ``(right)`` is only appended when ``subplots=False``.
        z (right))ri   rd   r  )rW   rf   r  s      rO   _mark_right_labelzMPLPlot._mark_right_labelI  s9     } 	  	 T]]55I5I 	 ZErQ   handler<   c                n    | j                             |           | j                            |           dS )z
        Append current handle and label to ``legend_handles`` and ``legend_labels``.

        These will be used to make the legend.
        N)r   r   r   )rW   r  rf   s      rO   _append_legend_handles_labelsz%MPLPlot._append_legend_handles_labelsT  s8     	""6***!!%(((((rQ   c                   |                      | j        d                   \  }}g }g }d}| j        s|}|                                                                }t          t          j                  t          d          k     r|j        }n|j	        }d |
                                D             }| j        r\| j        dk    r/|t          | j	                  z  }|t          | j                  z  }n|| j	        z  }|| j        z  }| j        | j        }t          |          dk    r|                    ||d|           d S d S | j        r;| j        r6| j        D ]0}|                                r|                    d           -d S d S d S )	Nr   rK  z3.7c                6    g | ]}|                                 S r]   )get_textr   xs     rO   r   z(MPLPlot._make_legend.<locals>.<listcomp>m  s     @@@1!**,,@@@rQ   reversebest)rN  r   )rN  )_get_ax_legendr  ri   	get_titler  r)   mpl__version__legendHandlesr   	get_textsrq   reversedr   r  r   get_visible)rW   r   leghandlesr  r   s         rO   r   zMPLPlot._make_legend^  s   %%dil33C} 	* A00223?++genn< 1!/GG!0G@@@@@{ 	.;)+ 1x(;<<<Ght'9:::FFt22Gd00F$ . -E7||a D		'6vU	CCCCCD D ] 	*t{ 	*i * *>>## *II&I)))	* 	* 	* 	** *rQ   c                    |                                  }t          | dd          pt          | dd          }d}||                                 }|||}|} | |fS )zQ
        Take in axes and return ax and legend under different scenarios
        r  Nr  )
get_legendrw  )r   r  other_ax	other_legs       rO   r  zMPLPlot._get_ax_legend  ss     mmoo2y$//P72z43P3P	 	. ++--I 	9 	CB3wrQ   c                    dd l m} |S r#  )r   r   )rW   r   s     rO   r   zMPLPlot.plt  s     	('''''
rQ   c                   | j         j        }|j        dv }| j        rt	          |t
                    r'|                                                                }nt          |j	                  r|                                }nt	          |t                    s|r|                                }nZd| _        t          t          t          |                              }n)t          t          t          |                              }|S )N)rR  date
datetime64timeT)r`   r  inferred_typern   r   r%   to_timestamp	_mpl_reprr   rD  r"   _need_to_set_indexr   ranger   )rW   r  is_datetyper  s       rO   _get_xtickszMPLPlot._get_xticks  s    	)-WW > 	(%00 ,&&((2244 +5;77 
,
 OO%%E#344 , ,OO%%*.'s5zz**++U3u::&&''ArQ   y
np.ndarrayis_errorbarc                "   t          |          }|                                r?t          j                            |          }t          j                            ||          }t          |t                    r|                                }|rkd|v r*t          j        |	                    d                    |d<   d|v r*t          j        |	                    d                    |d<    |j
        ||fi |S ||||fn||f} |j        |i |S Nr   r   )r'   r   r   maarraymasked_wherer   r#   r  geterrorbarplot)	r   r   r  r  rF   r  r   maskargss	            rO   _plotzMPLPlot._plot  s   
 Aww88:: 	,AA""4++Aa"" 	A 		*~ :!x(8(899V~ :!x(8(899V2;q!,,t,,, %*AAq%==Aq6D27D)D)))rQ   c                    | j         S )zCSpecify whether xlabel/ylabel should be used to override index name)rs   rV   s    rO   _get_custom_index_namezMPLPlot._get_custom_index_name  
    {rQ   c                V   t          | j        j        t                    rB| j        j        j        }t          j        | r d                    d |D                       }n%d }n"| j        j        j        }|t          |          }| 
                                }|t          |          }|S )Nr  c                ,    g | ]}t          |          S r]   r*   r  s     rO   r   z+MPLPlot._get_index_name.<locals>.<listcomp>  s     ? ? ?Qa ? ? ?rQ   )r   r`   r  r$   r  r   any_not_noner   rL  r+   r  )rW   rL  
index_names      rO   _get_index_namezMPLPlot._get_index_name  s    dio}55 		*9?(D& xx ? ?$ ? ? ?@@9?'D *#D)) 0022
 	,
++DrQ   r=  c                J    |rt          |d|          S t          |d|          S )z,get left (primary) or right (secondary) axesr  r  )rw  )r   r   r=  s      rO   r  zMPLPlot._get_ax_layer  s0      	/2y"---2z2...rQ   col_idxc                    t          | j        t                    r-t          fdt	          | j                  D                       S S )zJReturn the index of the axis where the column at col_idx should be plottedc              3  *   K   | ]\  }}|v 	|V  d S r\   r]   )r   	group_idxr   r  s      rO   	<genexpr>z/MPLPlot._col_idx_to_axis_idx.<locals>.<genexpr>  sF        &Ye#     rQ   )r   ri   r   next	enumerate)rW   r  s    `rO   _col_idx_to_axis_idxzMPLPlot._col_idx_to_axis_idx  sb     dmT** 		    *3DM*B*B      NrQ   ic                .   | j         rC|                     |          }| j        |         }|                     ||          }|| j        |<   n#| j        d         }|                     ||          }|                                                    d           |S )Nr   T)ri   r  r  r  r  r  )rW   r  r   s      rO   rh  zMPLPlot._get_ax   s     = 	0))!,,A1B((Q//BDIaLL1B((Q//B
""4(((	rQ   c                    t          | j        t                    r| j        S t          | j        t          t          t
          j        t          f          r| j        j	        |         | j        v S d S r\   )
r   rx   rI   r   r   r   r   r#   r`   r   )rW   r  s     rO   r  zMPLPlot.on_right  sb    d&-- 	$##d&bj((KLL 	<9$Q'4+;;;	< 	<rQ   r   dict[str, Any]col_numc                   d}| j         vt          | j         t                    r	 | j         |         }nM# t          $ r Y nAw xY wt          | j         t                    r| j                             ||          }n| j         }d|v p| j        du}|du pt          |           }|s| j        r>|r<t          |t                    r||         |d<   n||t          |          z           |d<   ||fS )z
        Manage style and color based on column number and its label.
        Returns tuple of appropriate style and kwds which "color" may be added.
        Nr   )
rF   r   r   
IndexErrordictr  r   rP   ri   r   )rW   r   r   r  rf   rF   	has_colornocolor_styles           rO   _apply_style_colorszMPLPlot._apply_style_colors  s    : 		#$*d++ # Jw/EE!   DDJ-- #
ue44
tO@t}D'@	C_U-C-C)C 	> 	>M 	>&$'' > &uW &wV'< =Wd{s   3 
A A r   
num_colors
color_kwdsc                    || j         }|dk    r| j        }n| j                            |          }t	          || j        |          S )Nr   )r  r   r   )r   r   r   r  r0   r   )rW   r  r  r   s       rO   _get_colorszMPLPlot._get_colors5  s^    
  	&J  	.JEEIMM*--E"!]
 
 
 	
rQ   rB   r   tuple[Any, NDFrameT]c                   |d|fS d }t          |t                    r |||          }nt          |t                    rnyt          |t                    r9 |||          }t	          j        |          }t	          j        ||df          }n+t          |t                    rZ||         j        }||j	        
                    |                   }t	          j        |          }t	          j        ||df          }nt          |          rbt          |          r"t	          j        t          |                    }nt	          j        |          }|j        }t          |t                    rb|d         dk    rVt	          j        |d          }|j        }|d         t!          |          k    r t#          dt!          |           d          ntt          |t                    r_|j        dk    rT|d         |k    s%|d         dk    s|d         t!          |          k    r#t#          d	| d
t!          |           d          t!          |          dk    rt	          j        ||df          }nJt'          |          r&t	          j        |g|t!          |          f          }nd|  d}t#          |          ||fS )a  
        Look for error keyword arguments and return the actual errorbar data
        or return the error DataFrame/dict

        Error bars can be specified in several ways:
            Series: the user provides a pandas.Series object of the same
                    length as the data
            ndarray: provides a np.ndarray of the same length as the data
            DataFrame/dict: error values are paired with keys matching the
                    key in the plotted DataFrame
            str: the name of the column within the plotted DataFrame

        Asymmetrical error bars are also supported, however raw error values
        must be provided in this case. For a ``N`` length :class:`Series`, a
        ``2xN`` array should be provided indicating lower and upper (or left
        and right) errors. For a ``MxN`` :class:`DataFrame`, asymmetrical errors
        should be in a ``Mx2xN`` array.
        Nc                :    |                     | j                  }|S r\   )reindexr  )r`   es     rO   match_labelsz.MPLPlot._parse_errorbars.<locals>.match_labelsa  s    		$*%%AHrQ   r   r      z>Asymmetrical error bars should be provided with the shape (2, )r   z;Asymmetrical error bars should be provided with the shape (z, 2, z	No valid z	 detected)r   r!   r  r&   r   
atleast_2dtilerG   r   r   dropr   r   r   r   expand_dimsr   r   r   r   )rf   errr`   r   r  evalues	err_shaper  s           rO   r   zMPLPlot._parse_errorbarsG  s   .  	:	 	 	
 c<(( =	",tS))CCT"" :	" Y'' 6	",tS))C-$$C'#|,,CC S!! /	"3i&G))#../D-((C'#|,,CC# )	"3 )mDII.. mC((	I $	** y|q/@ nS!,,I	Q<3t99, $;.1$ii; ; ;  
 D,// 	CHM 	q\W,!!) "!D		1
 %F+2F F9<TF F F   3xx1} 1gcGQ<00s^^ 	"'#d))$ CC /e...CS//!DyrQ   r   r   c                   i }t          ddg||g          D ]g\  }}|r`| j        |         }t          |t          t          f          r$|||                                v r	||         }nd }n|
|||         }||||<   h|S r  )r}  r   r   r!   r  keys)	rW   rf   r  r   r   r   kwflagr  s	            rO   _get_errorbarszMPLPlot._get_errorbars  s     VV,tTl;; 	% 	%HB %k"ocL$#788 % #Uchhjj-@ #!%j" %3 %e*C %!$F2JrQ   c                    t          t          j                  t          d          k     rddlm nddlm fd|                                D             S )Nz3.8r   )Subplotr=   c                \    g | ](}t          |          |                                &|)S r\   )r   get_subplotspec)r   r   Klasss     rO   r   z)MPLPlot._get_subplots.<locals>.<listcomp>  sO     
 
 
2u%%
 +-*<*<*>*>

 
 
rQ   )r)   r  r  matplotlib.axesr  r>   get_axes)rW   r   r  s     @rO   ru  zMPLPlot._get_subplots  sz    3?##genn4 	68888888555555
 
 
 
llnn
 
 
 	
rQ   tuple[int, int]c                z   |                      |          }t                      }t                      }|D ]j}|                                                                }|                    |d         d                    |                    |d         d                    kt          |          t          |          fS )Nr   r   )ru  rM   get_position
get_pointsaddr   )rW   r   r  x_sety_setr   pointss          rO   rv  zMPLPlot._get_axes_layout  s    !!#&& 	$ 	$B__&&1133FIIfQil###IIfQil####E

CJJ''rQ   )rH   rG   )rH   rZ   )NNFNFTNNTNNNNNNNNNNNFNFNFN)*rg   rh   ri   rj   rk   rl   rm   rI   rn   rI   ro   rp   rq   rr   rs   rt   ru   rt   rv   rw   rx   ry   rz   rI   r{   rI   r|   rh   ra   r}   rb   r}   rc   r}   rd   rI   re   rI   rf   rt   rH   r~   )rk   rl   rH   rI   r   rG   r   r}   rH   r}   )ri   rj   r`   r   r   rG   rH   r   )r`   r   rH   r   r`   r   rH   r   )rH   r   rH   r~   )r   r>   rH   rI   )r   r>   r  r   rH   r>   )rH   r@   )rH   r!  )rH   r$  )rH   r(   r   r@   rH   r~   r   r>   rH   r~   NN)r  r?   rv   rw   rH   r~   )rf   rG   r  r   rH   rG   )r  r<   rf   rG   rH   r~   )r   r>   )NFr   r>   r  r  r  rI   )T)r=  rI   )r  r   rH   r   )r  r   )r   r  r  r   rf   rG   )Nr   )r  rw   r  rG   )rf   rG   r`   rB   r   r   rH   r  )NNTT)r   rI   r   rI   rH   r  )r   r@   )r   r@   rH   r  )>__name__
__module____qualname____doc__propertyr   rX   r6  r   r^   __annotations__r   r   staticmethodr   classmethodr   r   r   r   r   r   r   r  r
  r  r   r   r  r   rA  rI  r   r   r   r   r  r  r  rk  r  r  r  r   r  r   r  r  r-   r  r  r  r  r  rh  r  r  r  r   r  ru  rv  r]   rQ   rO   rS   rS   l   s          " " " ^ X" LL   X OOO
  $38".2!"&"&#8="$(9Y2< .3-2/4!%IY2 Y2 Y2 Y2 Y2 Y2v    \ U 
 
 
 [
 g g g \ UgR% % %N 1 1 1 \ U1
! 
! 
! 
! , , , X U, ' ' ' U' 
1 
1 
1 U
1 U U U \ UU ! ! ! U!F % % % ^ U% % % % ^ U% $ $ $ ^ U$L $ $ X$0   \ U$    U #G #G #G U#GJ( ( ( (    U    U4 F F F ^F ;3 ;3 ;3 U;3z 591 1 1 1 \ U1$ ) ) ) X U)    U ) ) ) U)"* "* "* "*H    \ U   ^ U
 
  U8 *IN* * * * +* [*,      U& / / / / [ U/    U    U < < < U<    U< "&!
 
 
 
 
$ \ \ \ \ U\| FJ    U* 

 

 

 U

 	( 	( 	( U	( 	( 	(rQ   rS   c                  f    e Zd ZdZdZddZedd	            Zedd            Zedd            Z	dS )	PlanePlotzM
    Abstract class for plotting on plane, currently scatter and hexbin.
    singlerH   r~   c                z   t          j        | |fi | ||t          | j        dz             t	          |          r0| j        j                                        s| j        j        |         }t	          |          r0| j        j                                        s| j        j        |         }|| _        || _	        d S )Nz requires an x and y column)
rS   r   r   rX   r   r`   r   _holds_integerr  r  )rW   r`   r  r  kwargss        rO   r   zPlanePlot.__init__  s    t..v... 	I 	ITZ*GGHHHa== 	%!2!A!A!C!C 	%	!!$Aa== 	%!2!A!A!C!C 	%	!!$ArQ   r`   r   r   c                    dS r  r]   r   s     rO   r   zPlanePlot._get_nseries  s    qrQ   r   r>   c                    | j         | j        }}| j        | j        nt          |          }| j        | j        nt          |          }|                    |           |                    |           d S r\   )r  r  rs   r+   ru   
set_xlabelr|  )rW   r   r`   r  r  rs   ru   s          rO   r  zPlanePlot._post_plot_logic  sk    vtv1 $L\!__ $L\!__ 	f
frQ   r   r@   c               <    |j         d         } |j        |fd|i|S )Nr   r   )collectionscolorbar)rW   r   r   r   imgs        rO   _plot_colorbarzPlanePlot._plot_colorbar  s/    " nR s|C//B/$///rQ   Nr	  r  r  )r   r>   r   r@   )
r  r  r  r  r6  r   r   r   r  r#  r]   rQ   rO   r  r    s          L
 
 
 
    U    U 0 0 0 U0 0 0rQ   r  c                  p     e Zd Zedd            Z	 	 dej        ddd fd	ZddZddZ	ddZ
ddZ xZS )ScatterPlotrH   Literal['scatter']c                    dS )NrU  r]   rV   s    rO   rX   zScatterPlot._kind  s    yrQ   N)r!  normr!  bool | lib.NoDefaultr~   c               @   |d}n t          |          r||j        v r||         }|| _        || _        || _         t                      j        |||fi | t          |          r0| j        j        	                                s| j        j        |         }|| _
        d S )N   )r   r   r   r!  r(  superr   r   r`   r  c)
rW   r`   r  r  r   r-  r!  r(  r  	__class__s
            rO   r   zScatterPlot.__init__  s      	 AA^^ 	T\ 1 	QA 	q!..v...a== 	%!2!A!A!C!C 	%	!!$ArQ   r   r@   c           	        | j         | j        | j        | j        f\  }}}}| j        d         }t          |          o|| j        j        v }|o$t          | j        |         j        t                    }| j
        }	|                     |	||          }
|                     |
|          \  }}|                     |
|          }| j        r| j        }nd } |j        ||         j        ||         j        f|
|||| j        d| j        }|r|r|nd}|                     |||          }|rt+          | j        |         j        j                  }|                    t3          j        d|dz
  |                     |j                            | j        |         j        j                   ||                     ||           |                     |dd          }|                     |dd          }t+          |          dk    st+          |          dk    rSt?          |fi |}|                                 d         |d	<    |j!        ||         j        ||         j        fd
di| d S d S )Nr   )r-  rf   r   r(  r   rK  )r   rf         ?F)rf   r  r   )rf   r  r   ecolor	linestylenone)"r  r  r-  r`   r  r   r   r   rD  r   r   _get_c_values_get_norm_and_cmap_get_colorbarrq   rf   rU  r   r   r   r#  r   cat
categories	set_ticksr   linspacer   set_yticklabelsr  r  r  get_facecolorr  )rW   r   r  r  r-  r`   r   c_is_columncolor_by_categoricalr   c_valuesr(  r   cbrf   rU  
cbar_labelcbarn_catserrors_xerrors_yerr_kwdss                         rO   r   zScatterPlot._make_plot.  s   	91aYq\!!nn?di.?)?*  
zIaL 00
 0
 
%%e-A;OO,,X7KLL
d+66; 	JEEE"*GNGN	
 f	
 	
 i	
 	
  	E)1rJ&&rs*&EED# ETYq\-899r{3fEEFFF''	!(8(CDDD 	.. 	   &&Qae&DD&&Qae&DDx==1 	VH 1 	VH1111H!(!6!6!8!8!;HXBKQQUU&UHUUUUU	V 	VrQ   r>  rI   r=  c                    | j         }||t          d          ||| j        j        d         }n6||}n1|r| j        |         j        j        }n|r| j        |         j        }n|}|S )Nz&Specify exactly one of `c` and `color`zpatch.facecolor)r-  r   r   r   r`   r7  codesr   )rW   r   r>  r=  r-  r?  s         rO   r4  zScatterPlot._get_c_valuesb  s    F 	FU 	FDEEE 		 		x():;HH 	HH! 	y|'-HH 	y|*HHHrQ   c                   | j         }| j        %t          j                            | j                  n9t          |t                    s"t          |          rt          j        d         nd |rddlm	} t          | j        |         j        j                  }|                    fdt          j                  D                       t#          j        d||dz             }|                    |j                  }n| j        }|fS )NGreysr   )r   c                &    g | ]} |          S r]   r]   )r   r  r   s     rO   r   z2ScatterPlot._get_norm_and_cmap.<locals>.<listcomp>  s!    )I)I)Ia$$q'')I)I)IrQ   r   )r-  r   r  	colormapsget_cmapr   rG   r   
matplotlibr   r   r`   r7  r8  ListedColormapr  Nr   r:  BoundaryNormr(  )	rW   r?  r>  r-  r   rC  boundsr(  r   s	           @rO   r5  zScatterPlot._get_norm_and_cmapr  s   F= 		=))$-88DD Hc** 	/?/I/I 	=)DDD 
	D 
	))))))1)455F(()I)I)I)I5==)I)I)IJJD[FFQJ77F&&vtv66DD 9DTzrQ   c                d    | j         p|}| j        }|t          j        u rt	          |          o|S |S r\   )r   r!  r   r   r   )rW   r?  r=  plot_colorbarr@  s        rO   r6  zScatterPlot._get_colorbar  s?     4] 	@#H--?-?	rQ   )rH   r&  r  )r!  r)  rH   r~   r
  )r>  rI   r=  rI   )r>  rI   )r=  rI   rH   rI   )r  r  r  r  rX   r   r   r   r   r4  r5  r6  __classcell__r.  s   @rO   r%  r%    s           X 
 *-       82V 2V 2V 2Vh       4       rQ   r%  c                  P     e Zd Zedd            Zdddd fd
ZddZddZ xZS )
HexBinPlotrH   Literal['hexbin']c                    dS )Nhexbinr]   rV   s    rO   rX   zHexBinPlot._kind  s    xrQ   NT)r!  r!  rI   r~   c               
    t                      j        |||fi | t          |          r0| j        j                                        s| j        j        |         }|| _        || _        t          | j        | j	                 
                                          dk    rt          | j        dz             t          | j        | j                 
                                          dk    rt          | j        dz             d S )Nr   z  requires x column to be numericz  requires y column to be numeric)r,  r   r   r`   r   r  Cr!  r   r  _get_numeric_datar   rX   r  )rW   r`   r  r  r]  r!  r  r.  s          rO   r   zHexBinPlot.__init__  s    q!..v...a== 	%!2!A!A!C!C 	%	!!$A  ty 224455: 	NTZ*LLMMMty 224455: 	NTZ*LLMMM	N 	NrQ   r   r@   c                p   | j         | j        | j        | j        f\  }}}}| j        d         }| j        pd}t          j                            |          }| j	        }|d }	n||         j
        }	 |j        ||         j
        ||         j
        f|	|d| j         |r|                     ||           d S d S )Nr   BuGn)r]  r   )r   )r  r  r`   r]  r  r   r  rL  rM  r!  r   r[  r   r#  )
rW   r   r  r  r`   r]  r   r   r@  r?  s
             rO   r   zHexBinPlot._make_plot  s    	4691dAYq\}&}%%d++] 	&HHAw~H	$q'.$q'.UH4UU49UUU 	-,,,,,	- 	-rQ   c                    d S r\   r]   rV   s    rO   r   zHexBinPlot._make_legend      rQ   )rH   rY  r\   )r!  rI   rH   r~   r
  r	  )	r  r  r  r  rX   r   r   r   rU  rV  s   @rO   rX  rX    s           XNt N N N N N N N N- - - -"       rQ   rX  c                  T   e Zd ZdZed"d            Zed#d            Zd$dZed%d
            Z	ed%d            Z
d&dZe	 	 	 d'd(d            Zed)d*d            Zed+d            Zeed,d                        Zeed-d                        Zeed.d                         Zd/d!ZdS )0LinePlotr   rH   rC   c                    dS NrY   r]   rV   s    rO   r^   zLinePlot.orientation      zrQ   -Literal['line', 'area', 'hist', 'kde', 'box']c                    dS )Nr   r]   rV   s    rO   rX   zLinePlot._kind      vrQ   r~   c                   ddl m} t          j        | |fi | | j        r | j                            d          | _        |d         | _        d| j        v r.t          | j        
                    d                    | _        d S d S )Nr   )plot_paramsr   x_compat)pandas.plottingrl  rS   r   re   r`   fillnarn  r   rI   r   )rW   r`   r  rl  s       rO   r   zLinePlot.__init__  s    //////t..v...< 	2	((q(11DI#J/" 	< z!:!:;;DMMM	< 	<rQ   rI   c                H    | j          o| j        o|                                 S r\   )rn  rn   _use_dynamic_xrV   s    rO   _is_ts_plotzLinePlot._is_ts_plot  s'     = MT^M8K8K8M8MMrQ   c                R    t          |                     d          | j                  S r#  )r5   rh  r`   rV   s    rO   rr  zLinePlot._use_dynamic_x  s    T\\!__di888rQ   r   r@   c           	     >   |                                  rKt          |                     d          | j                  }|j        }| j        }|                                }n6|                                 }| j        }| 	                    | j                  }| 
                                }t          j        | j                                         }|                                 }t!          |          D ])\  }	\  }
}|                     |	          }| j                                        }| j        
| j        |d<   |                     |||	|
          \  }}|                     |
|	          }t-          |fi |}t/          |
          }
|                     |
|	          }
|
|d<    ||||f||	||d|}|                     |d         |
           |                                  r7t5          |          }t7          |          \  }}|                    ||           +d S )Nr   rH  r   rf   r  r  rf   )rF   
column_numstacking_idr  )rs  r3   rh  r`   r  _ts_plotr   r  r  r   _get_stacking_idr   r  r   r   r  r  r   rQ  r   r  r  r  r+   r  r  r9   r:   r{  )rW   r   r`   r  plotfitry  r  r   r  rf   r  r   r   rF   r   newlinesr  leftrights                       rO   r   zLinePlot._make_plot  s<    	1&t||A	BBD
AMEBB  ""A JE di00B++--&(:(:(<(<=!!##&r]] &	) &	)MAzqaB9>>##Dz + $
W22  KE4 ((uA(>>F''''D ''E**5*::E!DMu	 ''	 	 	 	H ..x{EBBB!! ) &b))&uooeD%(((M&	) &	)rQ   Nr   r>   r  r  c                    |dk    r$|                      ||t          |                     |                     ||||d                   }t          j        |||fd|i|}	|                     |||           |	S )Nr   rf   rF   )_initialize_stackerr   _get_stacked_valuesrS   r  _update_stacker)
r   r   r  r  rF   rx  ry  r   y_valuesr  s
             rO   r  zLinePlot._plot  s     ? 	=##BSVV<<<**2{AtG}MMb!XCCUCdCCBQ///rQ   r`   rE   c                   t          |||          \  }}t          ||           t          |d          rt          |j        |           t          |d          rt          |j        |           |j                            || j        |f            | j        ||j	        t          j        |j                  fd|i|}t          ||j        |j	                   |S )Nr  r  rF   )r4   r1   r  r  r  
_plot_datar   rX   r  r  r   r   r   r2   freq)rW   r   r  r`   rF   r   r  r  s           rO   rz  zLinePlot._ts_plot0  s    
 $D"d33
d 	b$2y!! 	,"*d+++2z"" 	-"+t,,,
dDJ5666
2tz2:dk+B+BXX%XSWXX 	BGTZ000rQ   rw   c                <    | j         rt          | j                  S d S r\   )re   idr`   rV   s    rO   r{  zLinePlot._get_stacking_idG  s    < 	di== 4rQ   nr   c                    |d S t          |d          si |_        t          |d          si |_        t          j        |          |j        |<   t          j        |          |j        |<   d S )N_stacker_pos_prior_stacker_neg_prior)r  r  r  r   zeros)r   r   ry  r  s       rO   r  zLinePlot._initialize_stackerN  sw      	Fr/00 	'$&B!r/00 	'$&B!-/Xa[[k*-/Xa[[k***rQ   ry  r   c                8   ||S t          |d          s$|                     ||t          |                     |dk                                    r|j        |         |z   S |dk                                    r|j        |         |z   S t          d| d          )Nr  r   zWWhen stacked is True, each column must be either all positive or all negative. Column 'z,' contains both positive and negative values)r  r  r   allr  r  r   )r   r   ry  r   rf   s        rO   r  zLinePlot._get_stacked_values^  s    
  	Mr/00 	B##BS[[AAAaK 	 %k2 k   	 %k2
 KK K K
 
 	
rQ   c                    |d S |dk                                     r|j        |xx         |z  cc<   d S |dk                                     r|j        |xx         |z  cc<   d S d S r#  )r  r  r  )r   r   ry  r   s       rO   r  zLinePlot._update_stacker|  s      	FaK 	9!+...&8.....k   	9!+...&8.....	9 	9rQ   c                   ddl m} fd| j        rZ|                                }fd|D             }|j                             ||                     |                    |           |                                  o(j        j	        o| j
        o| j         p| j        o| j        }|                                 }|r$| j        sd| _        t!          || j                   || j
        r|                    |           d S d S d S )Nr   )FixedLocatorc                    t          |           r#|                                 rt          |           } 	 t          j        |                    S # t
          $ r Y dS w xY w)NrK  )r   r   r   r+   r  	Exception)r  r`   s    rO   	get_labelz,LinePlot._post_plot_logic.<locals>.get_label  sf    {{ q||~~ FF#DJqM222   rrs   A 
AAc                &    g | ]} |          S r]   r]   )r   r  r  s     rO   r   z-LinePlot._post_plot_logic.<locals>.<listcomp>  s!    888A99Q<<888rQ      )r   )matplotlib.tickerr  r  
get_xticksrl  set_major_locatorset_xticklabelsrr  r  _is_all_datesrn   ri   rk   r  r   r   r8   r  )	rW   r   r`   r  r   xticklabels	conditionr  r  s	     `     @rO   r  zLinePlot._post_plot_logic  sb   222222	 	 	 	 	 " 	,]]__F8888888K H&&||F';';<<<{+++ ##%%% G)<dnG]"Et}'D 	 ))++
 	1 = rtx0000 	&dn 	&MM*%%%%%	& 	& 	& 	&rQ   rH   rC   )rH   rh  r	  )rH   rI   r
  )NNN)r   r>   r  r  r\   )r   r>   r`   rE   )rH   rw   )r   r>   r  r   rH   r~   )r   r>   ry  rw   r   r  rH   r  )r   r>   ry  rw   rH   r~   r  )r  r  r  r   r  r^   rX   r   r   rs  rr  r   r  r  rz  r{  r  r  r  r  r]   rQ   rO   rd  rd    s       L   X    X< < < < N N N UN 9 9 9 U9<) <) <) <)~      [&     U,    U 9 9 9 [ U9 
 
 
 [ U
8 9 9 9 [ U9(& (& (& (& (& (&rQ   rd  c                  X    e Zd Zedd            ZddZe	 	 	 	 ddd            ZddZdS )AreaPlotrH   Literal['area']c                    dS )Nr   r]   rV   s    rO   rX   zAreaPlot._kind  rj  rQ   r~   c                   |                     dd           t          j                    5  t          j        ddt                     |                    d          }d d d            n# 1 swxY w Y   t          j        | |fi | | j        s| j	                             dd	           | j
        s| j        rt          d
          d S )Nre   TignorezDowncasting object dtype arrays)rW  r   rm  alphar0  z+Log-y scales are not supported in area plot)
setdefaultr   catch_warningsfilterwarningsFutureWarningrp  rd  r   re   r   rb   rc   r   )rW   r`   r  s      rO   r   zAreaPlot.__init__  s#   )T***$&& 	( 	(#1&   
 ;;Q;''D	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	$/////| 	/I  #...9 	L 	LJKKK	L 	Ls   3A))A-0A-NFr   r>   r  r  r  rI   c                
   |dk    r$|                      ||t          |                     |                     ||||d                   }	|                                }
|
                    d           t          j        |||	fd|i|
}|d                             d          \  }}	|"t          j	        t          |                    }nm|dk    
                                r|j        |         }nG|dk    
                                r|j        |         }n!t          j	        t          |                    }d|vr|d                                         |d<    |j        |||	fi |}|                     |||           |g}|S )Nr   rf   rF   F)origr   )r  r   r  rQ  r   rS   r  get_datar   r  r  r  r  	get_colorfill_betweenr  )r   r   r  r  rF   rx  ry  r  r   r  	line_kwdsr  xdatastartrectress                   rO   r  zAreaPlot._plot  s    ? 	=##BSVV<<<**2{AtG}MM IIKK	gb!XHHUHiHH  (+++77x  		%HSVV$$EE1f\\^^ 	%)+6EE1f\\^^ 	%)+6EEHSVV$$E$ 	1!!H..00DMrueX>>>>BQ/// f
rQ   c                   t                               | ||           t          t          |                                                    dk    }| j        |s|dk                                                                    r|                    dd            d S |dk                                                                    r|                    d d           d S d S d S d S r#  )rd  r  r   r   get_shared_y_axesr   r  rz  )rW   r   r`   is_shared_ys       rO   r  zAreaPlot._post_plot_logic  s    !!$D111$r33556677!;9 	%[ 	%	  $$&& %At$$$$$!)""&&(( %D!$$$$$		% 	% 	% 	%% %rQ   )rH   r  r	  )NNNFr  r  )	r  r  r  r  rX   r   r  r  r  r]   rQ   rO   r  r    s           XL L L L&  !+ + + + [+Z	% 	% 	% 	% 	% 	%rQ   r  c                      e Zd Zed(d            ZdZed)d            Zdddd	d	d
dd*dZed+d            Z	ed             Z
ed             Ze	 	 d,d-d            Zed             Zd.dZd/dZd0d&Zd'S )1BarPlotrH   Literal['bar', 'barh']c                    dS )Nr   r]   rV   s    rO   rX   zBarPlot._kind      urQ   Z   rC   c                    dS rf  r]   rV   s    rO   r^   zBarPlot.orientation  rg  rQ   centerr   r0  F)alignbottomr  widthpositionr  r~   c                  t          |t                    | _        || _        || _        || _        t          j        t          |                    | _	        t          |          rt          j        |          }t          |          rt          j        |          }|| _        || _        || _        t          j        | |fi | d S r\   )r   r&   
_is_series	bar_width_align	_positionr   aranger   tick_posr   r  r  r  r  rS   r   )	rW   r`   r  r  r  r  r  r  r  s	            rO   r   zBarPlot.__init__  s     %T955!	#d)),, 	&Xf%%F 	"8D>>D	t..v.....rQ   r  c                     | j         | j        z
  S r\   )r  
tickoffsetrV   s    rO   ax_poszBarPlot.ax_pos/  s    }t..rQ   c                    | j         s| j        r| j        | j        z  S | j        dk    r'| j        | j        z  }| j        | j        dz
  z  |dz  z   S | j        | j        z  S )Nedger0  )re   ri   r  r  r  r   rW   ws     rO   r  zBarPlot.tickoffset3  sm    < 	34= 	3>DN22[F" 	3-A>T^c%9:QWDD>DN22rQ   c                    | j         s| j        r| j        dk    r
| j        dz  S dS | j        dk    r| j        | j        z  }|dz  S dS )Nr  r  r   r0  )re   ri   r  r  r   r  s     rO   
lim_offsetzBarPlot.lim_offset=  sa    < 		4= 		{f$ ~))q[F" 	-As7N1rQ   r   r>   r  r  int | npt.NDArray[np.intp]r  rI   c                (     |j         |||f||d|S )N)r  r  )r   r   r   r  r  r  r  r  r   s           rO   r  zBarPlot._plotK  s)     rvaA=e=====rQ   c                    | j         S r\   )r  rV   s    rO   _start_basezBarPlot._start_baseX  r  rQ   r   r@   c                   |                                  }t          |          }t          j        t          | j                            x}}| j        }| j                            d          }t          |                     |                    D ]K\  }\  }	}
| 	                    |          }| j
                                        }| j        r||d<   n/t          |t                    r||	         |d<   n|||z           |d<   |                     |	|          }t          |fi |}t!          |	          }	|                     |	|          }	d|v sd|v r*|                    d          t&          j        d	         |d<   d}| j        r|
d
k                                    rd
}|| j        z   }| j        |d<   | j        rG| j        dz  } | j        || j        |z   |
| j        f||	| j        d|}|                    |	           n| j        r|
dk    }t          j        |||          | j        z   }| j        dz  } | j        || j        |z   |
| j        f||	| j        d|}|t          j        ||
d          z   }|t          j        |d|
          z   }n2| j        |z  } | j        || j        |dz   |z  z   |
|f||	| j        d|}|                      ||	           Md S )Nr   rH  r   rv  rw  r   r   r1  zxtick.colorr   r  r  )r  rf   r  r0  )!r  r   r   r  r`   r   rp  r  r   rh  r   rQ  r  r   r  r  r+   r  r  r  r   r  r  r  r  ri   r  r  r  r~  re   wherer  )rW   r   r   ncolors	pos_prior	neg_priorKr`   r  rf   r  r   r   r   r  r  r  r  s                     rO   r   zBarPlot._make_plot\  sf   !!##f++ "TY 8 88	ILy""&tD'A'ABB B	< B	<MAzqaB9>>##D 4 &WFD)) 4 &uW &q7{ 3W((uA(>>F''''D ''E**5*::E4 =Vt^ =488H;M;M =!$m!<XEx Q!VLLNN D,,E KDM} (NQ&!tzK!ON		
  	 	 	 	 U#### 1uy)<<t?OONQ&!tzK!ON		
  	 	 	 	 &q!(<(<<	%q!(<(<<		NQ&!tzK1s7a-/		
  	 	 	 	 ..tU;;;;EB	< B	<rQ   c                F   | j         rd |j        D             }n$d t          |j        d                   D             }| j        d         dz
  | j        z   }| j        d         dz   | j        z   | j        z   }|                     ||                                 |||           d S )Nc                ,    g | ]}t          |          S r]   r*   r   keys     rO   r   z,BarPlot._post_plot_logic.<locals>.<listcomp>  s     AAAsc**AAArQ   c                ,    g | ]}t          |          S r]   r*   r  s     rO   r   z,BarPlot._post_plot_logic.<locals>.<listcomp>  s     KKKsc**KKKrQ   r   g      ?r   )	rn   r  r  r   r  r  r  _decorate_ticksr  )rW   r   r`   	str_indexs_edgee_edges         rO   r  zBarPlot._post_plot_logic  s    > 	LAAdjAAAIIKKeDJqM6J6JKKKIQ$&8R4'$.84?JR!5!5!7!7FFSSSSSrQ   rL  rZ   
ticklabels	list[str]
start_edgerC  end_edgec                >   |                     ||f           | j        -|                    t          j        | j                             n/|                    | j                   |                    |           || j        r|                    |           d S d S d S r\   )	r{  r   ry  r   r  r  r  rn   r  rW   r   rL  r  r  r  s         rO   r  zBarPlot._decorate_ticks  s     	Z*+++; 	+MM"(4;//0000MM$-(((z*** 	  	 MM$	  	  	  	 rQ   N)rH   r  r  r	  )rH   r  r   Fr   r>   r  r  r  r  r  rI   r
  r  r   r>   rL  rZ   r  r  r  rC  r  rC  rH   r~   )r  r  r  r  rX   r   r^   r   r   r  r  r  r  r  r  r   r  r  r]   rQ   rO   r  r    sl          X L   X / / / / / /> / / / ^/ 3 3 ^3 
 
 ^
  -.
> 
> 
> 
> [
>   XJ< J< J< J<X	T 	T 	T 	T           rQ   r  c                      e Zd Zedd            ZdZedd            Zed             Ze	 	 dd d            Z	d Z
d!dZdS )"BarhPlotrH   Literal['barh']c                    dS )Nr   r]   rV   s    rO   rX   zBarhPlot._kind  rj  rQ   r   Literal['horizontal']c                    dS )Nrj  r]   rV   s    rO   r^   zBarhPlot.orientation  s    |rQ   c                    | j         S r\   )r  rV   s    rO   r  zBarhPlot._start_base  s
    yrQ   Fr   r>   r  r  r  r  r  rI   c                (     |j         |||f||d|S )N)r  r  )r   r  s           rO   r  zBarhPlot._plot  s)     rwq!Q<U<<t<<<rQ   c                    | j         S r\   )ru   rV   s    rO   r  zBarhPlot._get_custom_index_name  s
    {rQ   rL  rZ   r  r  r  rC  r  r~   c                   |                     ||f           |                    | j                   |                    |           || j        r|                    |           |                    | j                   d S r\   )rz  rx  r  r;  rn   r|  r  rs   r  s         rO   r  zBarhPlot._decorate_ticks  s     	Z*+++
dm$$$
:&&& 	  	 MM$ 	dk"""""rQ   N)rH   r  )rH   r  r  r  r  )r  r  r  r  rX   r   r^   r  r  r  r  r  r]   rQ   rO   r  r    s           X L   X   X  -.
= 
= 
= 
= [
=  # # # # # #rQ   r  c                  n     e Zd Zedd            ZdZdddZed fd            ZddZ	ddZ
ddZ xZS )PiePlotrH   Literal['pie']c                    dS )Nr   r]   rV   s    rO   rX   zPiePlot._kind  r  rQ   rj  Nr~   c                    |                     d          }|dk                                                                     rt          | j         d          t	          j        | |fd|i| d S )Nr   rm  z# plot doesn't allow negative valuesr   )rp  r   r   rX   rS   r   )rW   r`   r   r  s       rO   r   zPiePlot.__init__  sw    {{{##1H>>!! 	Q
OOOPPPt99$9&99999rQ   r   rG   r   r}   c                    t                                          ||           |dur,t          j        d| dt          t                                 dS )N)r   r   FzPiePlot ignores the 'z	' keywordr   )r,  r   r   r   UserWarningr   )r   r   r   r.  s      rO   r   zPiePlot._validate_log_kwd  si     	!!c!777 	M6666+--   
 urQ   c                    d S r\   r]   )rW   r   r   s      rO   r   zPiePlot._validate_color_args  r_   rQ   r   r@   c                \   |                      t          | j                  d          }| j                            d|           t          |                     | j                            D ]<\  }\  }}|                     |          }|$t          |          }|	                    |           | j        
                                }d d | j        j        D             }|                    d|          }	|	fdt          |	|          D             }
nd }
 |j        |fd|
i|}|                    dd           |\  }}}n|\  }}g }| j        "||z   D ]}|                    | j                   |	|	n|}t          ||          D ]\  }}|                     ||           >d S )	Nr   )r  r  rH  c                    |dk    rdS | S )Nr   rK  r]   )rf   r   s     rO   blank_labelerz)PiePlot._make_plot.<locals>.blank_labeler&  s    A: !2 LrQ   c                ,    g | ]}t          |          S r]   r*   )r   vs     rO   r   z&PiePlot._make_plot.<locals>.<listcomp>,  s    <<<q<??<<<rQ   r  c                .    g | ]\  }} ||          S r]   r]   )r   r  r   r  s      rO   r   z&PiePlot._make_plot.<locals>.<listcomp>2  s)    XXX+$==u55XXXrQ   autopct)r  r   r`   r   r  r  r   rh  r+   r|  rQ  r  r   r}  r   r  rv   r  r  )rW   r   r   r  rf   r  r   r   idxr  blabelsresultspatchestexts	autotextst	leglabels_patch	_leglabelr  s                      @rO   r   zPiePlot._make_plot  s   !!S^^!QQ	Xv...&tDI'F'FGG &	F &	FMAzqaB %$U++e$$$9>>##D! ! ! =<DIO<<<CXXh,,F  XXXXVUVXXXbfQ77w7$77Gxx	4(( ,3)		!(	} 2* 2 2ANN4=1111 #)=#I%()%<%< F F!	2269EEEEFK&	F &	FrQ   r   r>   c                    d S r\   r]   ro  s      rO   r  zPiePlot._post_plot_logicF  rb  rQ   )rH   r  r\   r	  r  r
  r  )r  r  r  r  rX   r6  r   r  r   r   r   r  rU  rV  s   @rO   r  r    s           X  L: : : : :      [   *F *F *F *FX       rQ   r  )rF   rG   rH   rI   )o
__future__r   abcr   r   collections.abcr   r   r   r	   typingr
   r   r   r   r   r   rN  r  numpyr   pandas._libsr   pandas.errorsr   pandas.util._decoratorsr   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   r   r   r   r   r   r   r   r   pandas.core.dtypes.dtypesr   r    pandas.core.dtypes.genericr!   r"   r#   r$   r%   r&   pandas.core.dtypes.missingr'   pandas.core.commoncorecommonr   pandas.core.framer(   pandas.util.versionr)   pandas.io.formats.printingr+   pandas.plotting._matplotlibr,   %pandas.plotting._matplotlib.converterr-   #pandas.plotting._matplotlib.groupbyr.    pandas.plotting._matplotlib.miscr/   !pandas.plotting._matplotlib.styler0   &pandas.plotting._matplotlib.timeseriesr1   r2   r3   r4   r5   !pandas.plotting._matplotlib.toolsr6   r7   r8   r9   r:   r;   matplotlib.artistr<   r  r>   matplotlib.axisr?   matplotlib.figurer@   pandas._typingrA   rB   rC   rD   pandasrE   rP   rS   r  r%  rX  rd  r  r  r  r  r]   rQ   rO   <module>r6     s   " " " " " "                                               - - - - - - 2 2 2 2 2 2 4 4 4 4 4 4                                                , + + + + +                   ' ' ' ' ' ' ' ' ' ' ' ' 3 3 3 3 3 3 - - - - - - W W W W W W H H H H H H C C C C C C A A A A A A                              (((((($$$$$$$$$$$$((((((            2 2 2 2h( h( h( h( h(c h( h( h(V#30 30 30 30 30 30 30 30lG G G G G) G G GT% % % % % % % %Pq& q& q& q& q&w q& q& q&hO% O% O% O% O%x O% O% O%d         g      D0# 0# 0# 0# 0#w 0# 0# 0#fM M M M Mg M M M M MrQ   