a
    Pf<                    @   s   d Z ddlmZmZ ddlZddlZddlZddlZddlZddlZ	ddl
Z
ddlm  mZ ddlmZ ddlZddlmZmZmZmZmZmZmZmZ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*m+Z+m,Z, ddl-m.Z. e
/dZ0e
/d	Z1G d
d dZ2dd Z3dS )z Test cases for DataFrame.plot     )datedatetimeN)is_list_like)		DataFrameIndex
MultiIndexPeriodIndexSeriesbdate_range
date_rangeoption_contextplotting)_check_ax_scales_check_axes_shape_check_box_return_type_check_colors_check_data_check_grid_settings_check_has_errorbars_check_legend_labels_check_plot_works_check_text_labels_check_ticks_props_check_visible
get_y_axispprint_thing
matplotlibzmatplotlib.pyplotc                   @   s  e Zd Zejjdd Zejjdd Zejjdd Zejjdd Z	ejj
d	d
ejjdd Zejjdd Zejjejddg didg didddddddgdd Zejjdd Zejjdd Zejjdd Zejjd d! Zejjejd"d#d$gd%d& Zejjd'd( Zejd)ed*d+d,gd+d,gd+d,gd-d+gd-d+gd+d-gd+d-gd,d-gd,d-gd+d.gd+d.gd+d/gd+d/ggd0d1 Zejjejd2g d3d4d5 Zejjejd6d7i gd8i gd9i gd:d;d;igd<d=d;d>gd?d=d;d>ggd@dA ZdBdC ZdDdE ZdFdG ZdHdI ZdJdK ZdLdM ZejdNdOdPgdQdR ZejdSg dTdUdV Z dWdX Z!dYdZ Z"d[d\ Z#d]d^ Z$d_d` Z%dadb Z&ejdce'j(e'j)gddde Z*ejdfe+d;g dgig dhdie+d;djdke'j,dldmdndogidkdjdldpe'j,dldpgdigdqdr Z-dsdt Z.dudv Z/dwdx Z0ejdyd7dzgejd{d|d}gd~d Z1ejdyd7dzgdd Z2dd Z3ejdyd7dzgdd Z4ejde5de6dd.ddgdd Z7ejde5de6dd.ddgdd Z8ejde5de6dd.ddgejdi ddigdd Z9ejdi ddigdd Z:dd Z;ejj
dddejdddgdd Z<dd Z=ejdddgdd Z>dd Z?ejdddgejdddgdd Z@ejdddgdd ZAdd ZBdd ZCdd ZDdd ZEdd ZFejdeGeHjIgdd ZJejdd>dgdd ZKdd ZLdd ZMdd ZNejdddgdd ZOejddejPdeQRdádčgejdddgejdg dǢg dȢgddʄ ZSejdddgejdg d͢g d΢fddЄ ZTejdg dѢddӄ ZUejdddgdd؄ ZVddڄ ZWdd܄ ZXddބ ZYdd ZZdd Z[ejjejdi ddidddddigdd Z\ejjdd Z]ejjdd Z^ejjdd Z_dd Z`dd Zadd Zbdd Zcejdddd Zedd Zfdd Zgejdg ddd Zhd d Zidd Zjdd Zkdd Zldd	 Zmd
d Zndd Zodd Zpdd Zqdd Zrejdde'jsdd de'jsdd gdd ZtdddZuejde've'wg de'wg de've'wg de'wg d e've'wg de'wg d!d"e've'we'j,d|d#d$dd%ge'wg d&e've'wd|e'j,d#d$dd%ge'wg d'e've'wd|d#d$e'j,dd%ge'wg d(d"gd)d* Zxd+d, Zyejd-d.d/d0d֜d.d/dg d1d.d/ggd2d3 Zzd4d5 Z{ejd6g d7d8d9 Z|d:d; Z}ejdye~jjd<d= Zejdyd<d?gd>d? Zejdye~jjd@dA Zejdyee~jjdzg dBdC ZdDdE ZejdFd,d-gd+dGfd+gd,d-gdHdIgfgdJdK ZdLdM ZejdNdOd+gd,fgdPdQ ZejdRd+d,gdHgdSgfd+d,d-gdHdIgdSdTgfdUd|d#gdVdWgdXdYgfgdZd[ Zejd\dUd|d+d,gfd|dUdUd|gfgd]d^ Zd_d` Zdadb Zejdcd#e'jgddde Zejdfi dgfdhdiidifdjdkidkfgdldm Zdndo Zejd;dpd#gdqdr Zdsdt Zdudv Zdwdx Zejjejddydidddzd{digd|d} Zejjd~d Zejjdd Zejjejdddgdd Zejjdd Zejjdd Zejjejdyg dejdee'sdd d=de+e'sdd e'sdd d>gdd Zejjejdyg dejde+e'sdd e'sdd d>e+e'sdd e'sdd d>fee'sdd d=dee'sdd d=dfdgdd Zejjejdyg ddd Zejj
deddd Zdd Zejjejdyd7d8gdd Zejjdd Zejjejddd e+gdd Zejdyg ddd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zejdye~jjdd Zdd Zdd Zdd ZdÐdĄ ZdŐdƄ ZdǐdȄ Zdɐdʄ Zejdg d̢d͐d΄ ZdϐdЄ Zdѐd҄ Zejdyd7dzgdӐdԄ ZdՐdք Zdאd؄ Zdِdڄ Zejdydۡdܐd݄ Zdސd߄ Zdd Zdd Zejdg ddd ZÐdd ZĐdd Zejdyddd Zejdddddd#dd|d#gfgejdyg ddd Zejdg dejdyd<d?gdd Zejdddd Zejjdd  Zd#S (  TestDataFramePlotsc                 C   sD   t tjddttdtdtddddd	}t	|j
d
d d S )N   
      ABCDdtype
2000-01-01r!   BperiodsfreqcolumnsindexF)grid)r   nprandomdefault_rngstandard_normalr   listobjectr   r   plotselfdf r9   _/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/plotting/frame/test_frame.py	test_plot7   s    zTestDataFramePlots.test_plotc                 C   sT   t tjddttdtdtddddd	}t	|j
d
d
d}t|ddd d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   Tdefault_axessubplotsr"   r"      axes_numlayoutr   r/   r0   r1   r2   r   r3   r4   r   r   r5   r   r7   r8   axesr9   r9   r:   test_plot_subplots@   s    z%TestDataFramePlots.test_plot_subplotsc                 C   sV   t tjddttdtdtddddd	}t	|j
d
d
dd}t|ddd d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   T)r   )r=   r>   rC   r"   r   r   rA   rD   rE   r9   r9   r:   "test_plot_subplots_negative_layoutK   s    z5TestDataFramePlots.test_plot_subplots_negative_layoutc                 C   sb   t tjddttdtdtddddd	}t	|j
d
d
dd}t|dd t|ddd d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   TF)r=   r>   	use_indexr   xrotr"   r?   rA   )r   r/   r0   r1   r2   r   r3   r4   r   r   r5   r   r   rE   r9   r9   r:   test_plot_subplots_use_indexZ   s    z/TestDataFramePlots.test_plot_subplots_use_indexzApi changed in 3.6.0)reasonc                 C   sZ   t ddgddgd}d}tjt|d |jjdd	 W d    n1 sL0    Y  d S )
Nr@   r      r"   xyz''Line2D' object has no property 'blarg'matchT)Zblarg)r   pytestraisesAttributeErrorr5   liner7   r8   msgr9   r9   r:   test_plot_invalid_argj   s    z(TestDataFramePlots.test_plot_invalid_argc                 C   sF   t tjddttjd d d}t|jdd}t	|dd d S )	Nr   r!   rP   r!   r-   TrK   r   rL   )
r   r/   r0   r1   r3   stringascii_lettersr   r5   r   r7   r8   axr9   r9   r:   test_plot_tick_propsr   s    z'TestDataFramePlots.test_plot_tick_propskwargsyticks)r@      r!   xticks)id   )ylimZxlimTblah)r=   r>   titlec                 C   s>   t tjddttjd d d}t|jfi | d S )Nr   r]   r!   r^   	r   r/   r0   r1   r3   r`   ra   r   r5   r7   re   r8   r9   r9   r:   test_plot_other_args|   s
    z'TestDataFramePlots.test_plot_other_argsc                 C   s   t tjddttjd d d}|jddd}t|dd	d
 |d d D ]F}t	|j
 t	| dd t	|jdddd t	|j
 gdd qP|d fD ]6}t	|j
 t	|  t	|j
 g t|dd qd S )Nr   r]   r!   r^   Trk   )r>   rl   rP   rP   r@   rA   Fvisibleminorr   rL   )r   r/   r0   r1   r3   r`   ra   r5   r   r   xaxisget_xticklabels	get_labelr   )r7   r8   rF   rc   r9   r9   r:   test_plot_visible_ax   s     	

z'TestDataFramePlots.test_plot_visible_axc                 C   s:   t tjddttjd d d}t|jdd d S )Nr   r]   r!   r^   rk   rl   rm   r6   r9   r9   r:   test_plot_title   s
    z"TestDataFramePlots.test_plot_titlec                 C   sV   t tjd d td}ttjddt	|d}t
|jdd}t|dd d S )	Nr!   r   r]   r^   Tr_   r   rL   )zipr`   ra   ranger   r/   r0   r1   r   from_tuplesr   r5   r   )r7   Ztuplesr8   rc   r9   r9   r:   test_plot_multiindex   s    z'TestDataFramePlots.test_plot_multiindexc                 C   s^   t jg dddgd}t jddgddgd}ttjd	d
dd||d}t|jdd d S )N))   αr   )r   r@   )   βr   )r   rP   )   γr"   )r   rg   )   δ   )r      Zi0i1)names)baru   Δ)r   u   ΕZc0c1r   r   r!   )   r   r+   u   Σry   )	r   r}   r   r/   r0   r1   integersr   r5   )r7   r-   r,   r8   r9   r9   r:   test_plot_multiindex_unicode   s    
z/TestDataFramePlots.test_plot_multiindex_unicoderC   N)rH   r@   c                 C   s>   t dtjddi}t|jjd|d}t|ddd d S )	NrR   r   r!   T)r>   rC   r@   r@   r@   rA   )r   r/   r0   r1   r   r5   r   r   )r7   rC   r8   rF   r9   r9   r:   test_plot_single_column_bar   s    z.TestDataFramePlots.test_plot_single_column_barc                 C   sb   t dtjddi}tj \}}|jjd|d}t	|dksHJ |j
}||d u s^J d S )NrR   r   r!   Tr>   rc   r@   r   )r   r/   r0   r1   mplpyplotr>   r5   r   lenrF   )r7   r8   _rc   rF   resultr9   r9   r:   test_plot_passed_ax   s    z&TestDataFramePlots.test_plot_passed_axz
cols, x, yZABCDEAr'   CDEc              
   C   st   g d}t g dg dtjddtjddgtdtj|dd	d
tj|dddd
d}t|| j	||d d S )N)Z2008Z2009NZ2011Z2012r@   r   rP   r"   rg   r   rg   rP   r   r$   z%Yformati8T)r   utcr   r'   r   r   r   rQ   )
r   r/   arraynanr4   pdto_datetimeviewr   r5   )r7   colsrR   rS   datesr8   r9   r9   r:   test_nullable_int_plot   s    
z)TestDataFramePlots.test_nullable_int_plotr5   )rY   r   histpiec                 C   s.   t jg ddd}t|}tt|j| d S )Nr@   r   rP   r"   UInt32r$   )r   r   r	   r   getattrr5   )r7   r5   arrsr9   r9   r:   test_integer_array_plot_series   s    z1TestDataFramePlots.test_integer_array_plot_serieszplot, kwargsrY   r   r   r   rS   scatterrR   rQ   hexbinc                 C   s<   t jg ddd}t||d}tt|j|fi | d S )Nr   r   r$   rQ   )r   r   r   r   r   r5   )r7   r5   re   r   r8   r9   r9   r:   test_integer_array_plot_df	  s    z-TestDataFramePlots.test_integer_array_plot_dfc                 C   s6   t g dg dd}| }t| dks2J d S )NrR   rS   zr@   r   rP   r   r'   r@   )r   r5   r   	get_linesrb   r9   r9   r:   test_nonnumeric_exclude  s    z*TestDataFramePlots.test_nonnumeric_excludec                 C   s@   t tjddg dd}|jddd}t|j d d S )Nr   r]   abcr,   r   r   rQ   )	r   r/   r0   r1   r2   r5   r   ru   rw   rb   r9   r9   r:   test_implicit_label   s
    z&TestDataFramePlots.test_implicit_labelc                 C   sH   t tjddddgd}d|j_|jddd |jjdksDJ d S )	Nr   rI   r   r   r   NAMEZLABEL)rS   label)r   r/   r0   r1   r2   r-   namer5   r6   r9   r9   r:   test_donot_overwrite_index_name'  s    z2TestDataFramePlots.test_donot_overwrite_index_namec                 C   s   t tjddttdtdtddddd	}t	|j
d
dd|dd 
  t	|j
d
d|d
  t	|j
d
d|j
  t	|j
ddd|dj
  t	|j
dd|d
  t	|j
dd|j
  d S )Nr   rg   r"   r#   r$   r&   rg   r'   r(   r+   r   r@   rQ   r   rR   rS   )r   r/   r0   r1   r2   r   r3   r4   r   r   r5   	set_indexr'   r6   r9   r9   r:   test_plot_xy0  s    " zTestDataFramePlots.test_plot_xyc                 C   s   t tjddttdtdtddddd	}t	d
t
|jd
 |_t|jd
dd|d
d   t|jd
d|d
  t|jd
d|d
   d S )Nr   r   r#   r$   r&   rg   r'   r(   r+   r@   rQ   r   r   )r   r/   r0   r1   r2   r   r3   r4   r   aranger   r,   r   r5   r   r6   r9   r9   r:   test_plot_xy_int_cols>  s    "z(TestDataFramePlots.test_plot_xy_int_colsc                 C   sd   t tjddttdtdtddddd	}|j	d
dddd}t
|jd t|d
ddd d S )Nr   r   r#   r$   r&   rg   r'   r(   r+   r@   ZTest)   r   )rR   rS   rl   figsizer   )g      0@g       @)rB   rC   r   )r   r/   r0   r1   r2   r   r3   r4   r   r5   r   rl   r   rb   r9   r9   r:   test_plot_xy_figsize_and_titleJ  s    z1TestDataFramePlots.test_plot_xy_figsize_and_titlezinput_log, expected_log)Tlog)symZsymlogc                 C   s   t dtditdd}|j|d}t||d | |ksDJ |j|d}t||d | |kslJ |j|d}t|||d	 | |ksJ | |ksJ d S )
Nr   ri   r^   logyyaxis)logxru   loglog)ru   r   )r   r/   r   r5   r   Z
get_yscaleZ
get_xscale)r7   Z	input_logZexpected_logr8   rc   r9   r9   r:   test_logscalesX  s    z!TestDataFramePlots.test_logscalesinput_param)r   r   r   c                 C   s   t dtditdd}d| d}tjt|d$ |jf i |di W d    n1 s`0    Y  d| d	}tjt	|d* |jj
f d
di|di W d    n1 s0    Y  d S )Nr   ri   r^   z	keyword 'z*' should be bool, None, or 'sym', not 'sm'rT   smzPiePlot ignores the 'z	' keywordr>   T)r   r/   r   rV   rW   
ValueErrorr5   tmassert_produces_warningUserWarningr   )r7   r   r8   r[   r9   r9   r:   test_invalid_logscalek  s    2z(TestDataFramePlots.test_invalid_logscalec                 C   sl   t tjddttdtdtddddd	}|j	d
d}|
 }t|d  tr\J t|dd d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   T)x_compatr      rL   )r   r/   r0   r1   r2   r   r3   r4   r   r5   r   
isinstance	get_xdatar   r   r7   r8   rc   linesr9   r9   r:   test_xcompatx  s    zTestDataFramePlots.test_xcompatc                 C   sr   t tjddttdtdtddddd	}d
t	j
d< | }| }t|d  trbJ t|dd d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   Tzxaxis.compatr   r   rL   )r   r/   r0   r1   r2   r   r3   r4   r   r   plot_paramsr5   r   r   r   r   r   r   r9   r9   r:   test_xcompat_plot_params  s    
z+TestDataFramePlots.test_xcompat_plot_paramsc                 C   s   t tjddttdtdtddddd	}d
t	j
d< | }| }t|d  trbJ d}tjt|d* tt|d  tsJ W d    n1 s0    Y  d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   Fr   r   zPeriodDtype\[B\] is deprecatedrT   )r   r/   r0   r1   r2   r   r3   r4   r   r   r   r5   r   r   r   r   r   r   FutureWarningr7   r8   rc   r   r[   r9   r9   r:   !test_xcompat_plot_params_x_compat  s    
z4TestDataFramePlots.test_xcompat_plot_params_x_compatc                 C   s   t tjddttdtdtddddd	}t	j
d
dB | }| }t|d  trhJ t|dd W d    n1 s0    Y  d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   r   Tr   r   rL   )r   r/   r0   r1   r2   r   r3   r4   r   r   r   Zuser5   r   r   r   r   r   r   r9   r9   r:   (test_xcompat_plot_params_context_manager  s    z;TestDataFramePlots.test_xcompat_plot_params_context_managerc                 C   s   t tjddttdtdtddddd	}|	 }|
 }t|d
  trXJ d}tjt|d* tt|d
  tsJ W d    n1 s0    Y  t|d
d d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   r   zPeriodDtype\[B\] is deprecated rT   rL   )r   r/   r0   r1   r2   r   r3   r4   r   r5   r   r   r   r   r   r   r   r   r   r9   r9   r:   test_xcompat_plot_period  s    8z+TestDataFramePlots.test_xcompat_plot_periodc                 C   sP   t tjddttdddtdddddgd}|  tjj	d	d
 d S )Nr   )   r     r@      r   r   r-   r,   r   r   )
r   r/   r0   r1   r
   r   r5   r   r   Zaxhliner6   r9   r9   r:   test_period_compat  s    z%TestDataFramePlots.test_period_compatindex_dtypec                 C   s   t dtdittddd|dtjd}| }| d }| }t|d d df |d d df tjdd	}t	j
||jd
d d S )NrS   ri   c   rH   r$   )r-   r%   r   r@   )r%   r   F)Zcheck_index_type)r   r/   r   r   int64r5   r   Z
get_xydatar	   r   Zassert_series_equalrS   )r7   r   r8   rc   r   rsr9   r9   r:   test_unsorted_index  s    *z&TestDataFramePlots.test_unsorted_indexr8                 ?       @      @)r   r   r   r   r^   r   r   r   g      @g      @g      @r   c                 C   s\   |  }| \}}| }|t|d  d ks:J |t|d  d ksXJ d S )Nr   )r5   get_xlimr   r/   nanminget_datananmaxr7   r8   rc   xminxmaxr   r9   r9   r:   test_unsorted_index_lims  s
    z+TestDataFramePlots.test_unsorted_index_limsc                 C   sx   t g dg dd}|jddd}| \}}| }|t|d  d ksVJ |t|d  d kstJ d S )Nr   )g     V@g     V@g     @W@g      W@)rS   r   r   rS   rQ   r   )r   r5   r   r   r/   r   r   r   r   r9   r9   r:   test_unsorted_index_lims_x_y  s    z/TestDataFramePlots.test_unsorted_index_lims_x_yc                 C   s   t tjddttjd d g dd }d}tjt	|d |j
jdd	 W d    n1 sf0    Y  tjt	|d |j
jdd
 W d    n1 s0    Y  d S )Nr   r   r"   r   rR   rS   r   fourr   z+Log-y scales are not supported in area plotrT   Tr   r   )r   r/   r0   r1   r3   r`   ra   rV   rW   r   r5   arearZ   r9   r9   r:   test_negative_log  s    ,z$TestDataFramePlots.test_negative_logc                 C   sZ   t t|d  d }t||D ]0\}}|| d 7 }| d }t|| q$d S )Nr   r@   )r/   Zzerosr   r   r{   r   assert_numpy_array_equal)r7   Znormal_linesZstacked_linesbasenlslsyr9   r9   r:   _compare_stacked_y_cood  s
    z*TestDataFramePlots._compare_stacked_y_coodkindr  multr@   rH   c                 C   sV   |t tjddg dd }t|j|dd}t|j|dd}| |j|j d S )Nr   r  wrR   rS   r   r   Fr  stackedTr   r/   r0   r1   r   r5   r  r   )r7   r  r  r8   ax1ax2r9   r9   r:   test_line_area_stacked  s    z)TestDataFramePlots.test_line_area_stackedc                 C   s   t tjddtjddtjdd tjdd d}t|j|dd}t|j|dd}| |jd d |jd d  | |jdd  |jdd   d S )Nr   r   r  Fr  Tr  )r7   r  Zsep_dfr  r  r9   r9   r:   test_line_area_stacked_sep_df	  s     z0TestDataFramePlots.test_line_area_stacked_sep_dfc                 C   s~   t tjddttjd d g dd}t|j	dd d}t
jt|d	 |j	d
d W d    n1 sp0    Y  d S )Nr   r  r   r  r   Fr  zWhen stacked is True, each column must be either all positive or all negative. Column 'w' contains both positive and negative valuesrT   T)r   r/   r0   r1   r2   r3   r`   ra   r   r5   rV   rW   r   )r7   Zmixed_dfr[   r9   r9   r:   test_line_area_stacked_mixed  s    z/TestDataFramePlots.test_line_area_stacked_mixedc                 C   sD   t tjddg dd}||jd }t|j|ddd d S )Nr   r  r  r   r@   T)r  r   r  )r   r/   r0   r1   r   r-   r   r5   )r7   r  r8   Zdf2r9   r9   r:   #test_line_area_stacked_positive_idx)  s
    z6TestDataFramePlots.test_line_area_stacked_positive_idxidxr"   z	2023-01-1)r*   r)   c           	      C   s   ddt jdg}dt jddg}t||d|d}t|j}|jd  }|jd  }t jg dt jd}t	
t |jd| t jg d	t jd}t	
t |jd| t	
|jt g d
 t	
|jt g d d S )Nr@   r   rP   r   r   r^   r   r   r$   )rP   r   r@   )FFTF)FTFF)r/   r   r   r   r5   r   	get_ydatar   float64r   r	  deletedatamask)	r7   r  values1values2r8   rc   Zmasked1Zmasked2expr9   r9   r:   test_line_area_nan_df3  s    
z(TestDataFramePlots.test_line_area_nan_dfc                 C   s   ddt jdg}dt jddg}t||d|d}t jg dt jd}t jg dt jd}t|jd	d
}t|j	d 
 | t|j	d 
 ||  d S )Nr@   r   rP   r  r^   r@   r   r   rP   r$   rP   r   r   r@   Tr  r   )r/   r   r   r   r   r   r5   r   r	  r   r  )r7   r  r$  r%  r8   	expected1	expected2rc   r9   r9   r:   test_line_area_nan_df_stackedH  s    z0TestDataFramePlots.test_line_area_nan_df_stackedr  Fc           	      C   s   ddt jdg}dt jddg}t||d|d}t jg dt jd}t jg dt jd}t|jjfi |}t	|j
d	  | |rt	|j
d  | nt	|j
d  ||  t|jjd
d}t	|j
d	  | t	|j
d  | d S )Nr@   r   rP   r  r^   r(  r$   r)  r   Fr  )r/   r   r   r   r   r   r5   r  r   r	  r   r  )	r7   r  re   r$  r%  r8   r*  r+  rc   r9   r9   r:   "test_line_area_nan_df_stacked_areaW  s    z5TestDataFramePlots.test_line_area_nan_df_stacked_areasecondary_yc                 C   s~   t tjddg dd}|jf i |}| \}}| }||d  d d ks^J ||d  d d kszJ d S )Nr   r   rP   r   r   r   rH   )r   r/   r0   r1   r5   r   r   r   )r7   re   r8   rc   r   r  r   r9   r9   r:   test_line_limn  s    z TestDataFramePlots.test_line_limc                 C   s   t tjddg dd}|jddd}t|ddd	 |D ]l}t|d
sPJ t|dr^J | \}}| }||d 	 d d ksJ ||d 	 d d ks>J q>d S )Nr   r/  r   r   T)r.  r>   rP   rp   rA   Zleft_axright_axr   rH   )
r   r/   r0   r1   r5   r   hasattrr   r   r   )r7   r8   rF   rc   r   r  r   r9   r9   r:   test_line_lim_subplotsw  s    z)TestDataFramePlots.test_line_lim_subplotszX2020-12-01 this has been failing periodically on the ymin==0 assertion for a week or so.)strictrO   c           
      C   s   t tjddg dd}| }t|jj|d}| \}}| \}}|	 }	||	d 
 d d kspJ ||	d 
 d d ksJ |dksJ t|jj|d}| \}}|dksJ d S )Nr   r  r  r   r  r   rH   )r   r/   r0   r1   r   r5   r  r   get_ylimr   r   )
r7   r  r8   Zneg_dfrc   r   r  ZyminZymaxr   r9   r9   r:   test_area_lim  s    z TestDataFramePlots.test_area_limc                 C   s   t tjddddgd}tjjdddd\}\}}|j|d	d
 |j|d	d
 t|	||shJ t|	||s|J d S )Nr   r"   r   rR   rS   r   r@   T)shareyr  )rc   r  )
r   r/   r0   r1   r   r   r>   r5   r   Zjoined)r7   r8   figr  r  r9   r9   r:   test_area_sharey_dont_overwrite  s    z2TestDataFramePlots.test_area_sharey_dont_overwritec                 C   sF   t tjdd}|jj|dd}|jD ]}| dks,J q,d S )Nr   rg   rg   )r  	linewidth)	r   r/   r0   r1   r2   r5   r   patchesget_linewidth)r7   r  r8   rc   rr9   r9   r:   test_bar_linewidth  s    
z%TestDataFramePlots.test_bar_linewidthc                 C   s^   t tjdd}|jjddd}t|ddd |D ] }|jD ]}|	 dksBJ qBq8d S )Nr   r;  T)r<  r>   rg   )rg   r@   rA   )
r   r/   r0   r1   r2   r5   r   r   r=  r>  )r7   r8   rF   rc   r?  r9   r9   r:   test_bar_linewidth_subplots  s    
z.TestDataFramePlots.test_bar_linewidth_subplotsz	meth, dim)r   	get_width)barh
get_heightc                 C   sv   t tjdd}d}t|j|||d}|jD ]<}|s\t|| |t|j	 kspJ q4t|| |ks4J q4d S )Nr   r;  ?)r  width)
r   r/   r0   r1   r2   r   r5   r=  r   r,   )r7   methdimr  r8   rF  rc   r?  r9   r9   r:   test_bar_barwidth  s    
 z$TestDataFramePlots.test_bar_barwidthc                 C   s\   t tjdd}d}t|j||dd}|D ]$}|jD ]}t|| |ks<J q<q2d S )Nr   r;  rE  T)rF  r>   )r   r/   r0   r1   r2   r   r5   r=  )r7   rG  rH  r8   rF  rF   rc   r?  r9   r9   r:   test_barh_barwidth_subplots  s    
z.TestDataFramePlots.test_barh_barwidth_subplotsc                 C   s   t tjdd}|jjddd}dd |jD }|dgd ksHJ |jjd	g d
d}dd |jd d D }|g d
ksJ d S )Nr   r;  Fr@   )r  bottomc                 S   s   g | ]}|  qS r9   Zget_y.0pr9   r9   r:   
<listcomp>      zBTestDataFramePlots.test_bar_bottom_left_bottom.<locals>.<listcomp>   T)rH   c                 S   s   g | ]}|  qS r9   rL  rM  r9   r9   r:   rP    rQ  rg   )r   r/   r0   r1   r5   r   r=  r7   r8   rc   r   r9   r9   r:   test_bar_bottom_left_bottom  s    z.TestDataFramePlots.test_bar_bottom_left_bottomc                 C   s   t tjdd}|jjdtg dd}dd |jD }|dgd	 ksRJ |jjd
g dd}dd |jd d D }|g dksJ d S )Nr   r;  Fr@   r@   r@   r@   r@   )r  leftc                 S   s   g | ]}|  qS r9   get_xrM  r9   r9   r:   rP    rQ  z@TestDataFramePlots.test_bar_bottom_left_left.<locals>.<listcomp>r@   rR  Tr   c                 S   s   g | ]}|  qS r9   r[  rM  r9   r9   r:   rP    rQ  rg   )r   r/   r0   r1   r5   rC  r   r=  rW  r9   r9   r:   test_bar_bottom_left_left  s    z,TestDataFramePlots.test_bar_bottom_left_leftc                 C   s   t tjdd}|jjddd}|D ]&}dd |jD }|dgd ks*J q*|jjdtg d	d
}|D ]&}dd |jD }|dgd kspJ qpd S )Nr   r;  TrH   )r>   rK  c                 S   s   g | ]}|  qS r9   rL  rM  r9   r9   r:   rP    rQ  zDTestDataFramePlots.test_bar_bottom_left_subplots.<locals>.<listcomp>rg   rY  )r>   rZ  c                 S   s   g | ]}|  qS r9   r[  rM  r9   r9   r:   rP    rQ  r@   )	r   r/   r0   r1   r5   r   r=  rC  r   )r7   r8   rF   rc   r   r9   r9   r:   test_bar_bottom_left_subplots  s    z0TestDataFramePlots.test_bar_bottom_left_subplotsc                 C   sR   t dtjdgg dg dd}|j }g d}dd |jD }||ksNJ d S )	Nr!      rg   r!   r_  r   r   r'   r   	r!   r   r_  rg   r!   r_  r@   r   rP   c                 S   s   g | ]}|  qS r9   rD  rM  r9   r9   r:   rP    rQ  z3TestDataFramePlots.test_bar_nan.<locals>.<listcomp>r   r/   r   r5   r   r=  r7   r8   rc   expectedr   r9   r9   r:   test_bar_nan  s
     
zTestDataFramePlots.test_bar_nanc                 C   sz   t dtjdgg dg dd}|jjdd}g d}d	d
 |jD }||ksRJ dd
 |jD }g d}||ksvJ d S )Nr!   r_  r`  r   ra  Tr  rb  c                 S   s   g | ]}|  qS r9   rc  rM  r9   r9   r:   rP     rQ  z;TestDataFramePlots.test_bar_nan_stacked.<locals>.<listcomp>c                 S   s   g | ]}|  qS r9   rL  rM  r9   r9   r:   rP    rQ  )	r   r   r         $@r   g      4@g      .@rh  g      D@rd  re  r9   r9   r:   test_bar_nan_stacked  s     z'TestDataFramePlots.test_bar_nan_stackedc                 C   s   t tjdd|td|tdd}|j }|j	 }t
|tg d | dksfJ |jd  d	ks|J |jd
  dksJ |jjdd}t
|tg d | dksJ |jd  d	ksJ |jd
  dksJ d S )Nr   )r   rg   ZABCDEFZabcder   )r   r@   r   rP   r"   rg   )g      g      @r   g      пrH   g@Tr  g      @)r   r/   r0   r1   r2   r3   r5   r   ru   get_ticklocsr   r	  r   r   r=  r\  )r7   r  r8   rc   Zticksr9   r9   r:   test_bar_categorical  s     



z'TestDataFramePlots.test_bar_categoricalzx, yr@   r   c                 C   sD   t tjddttjd d g dd}t|j	j
||d d S )Nr   r  r   r  r   rQ   )r   r/   r0   r1   r2   r3   r`   ra   r   r5   r   r7   rR   rS   r8   r9   r9   r:   test_plot_scatter  s    z$TestDataFramePlots.test_plot_scatterc                 C   s   t tjddttjd d g dd}t	d}t
jt|d |jjdd	 W d    n1 sj0    Y  t	d
}t
jt|d |jjdd W d    n1 s0    Y  d S )Nr   r  r   r  r   z5scatter() missing 1 required positional argument: 'y'rT   rR   r   z5scatter() missing 1 required positional argument: 'x'rS   r   )r   r/   r0   r1   r2   r3   r`   ra   reescaperV   rW   	TypeErrorr5   r   rZ   r9   r9   r:   test_plot_scatter_error(  s    
,
z*TestDataFramePlots.test_plot_scatter_errorc                 C   sR   t tjddttjd d g dd}|jdddd	d
}t	|ddd d S )Nr   r  r   r  r   rR   rS   r   T)rR   rS   r  r>   r@   r   rA   )
r   r/   r0   r1   r2   r3   r`   ra   r5   r   rE   r9   r9   r:   test_plot_scatter_shape5  s    z*TestDataFramePlots.test_plot_scatter_shapec                 C   sv   t tjdddgd}tddddj|d< d	}tjt	|d
  |j
dddd W d    n1 sh0    Y  d S )Nr   r!   r   r   z
2014-01-01h)startr*   r)   Zdtimez9must be a string or a (real )?number, not 'datetime.time'rT   r   )r  rR   rS   )r   r/   r0   r1   r2   r   timerV   rW   rq  r5   rZ   r9   r9   r:   &test_raise_error_on_datetime_time_data?  s
    z9TestDataFramePlots.test_raise_error_on_datetime_time_datar   valsr   r@   c                 C   sT   t tdddddd}tjdddt|}t||d}t|j	j
||d	 d S )
Ni  r@      W)ru  r)   r*   r   r   rx  rQ   )r   r   r/   r0   r1   normalr   r   r   r5   r   )r7   rR   rS   r   ry  r8   r9   r9   r:   test_scatterplot_datetime_dataH  s    z1TestDataFramePlots.test_scatterplot_datetime_datainfer_stringZpyarrow)Zmarksr  b_colr   rP   r"   r   c                 C   sR   t d|4 tg d|d}t|jj||d W d    n1 sD0    Y  d S )Nzfuture.infer_stringra  r  rQ   )r   r   r   r5   r   )r7   r  rR   rS   r  r8   r9   r9   r:   test_scatterplot_object_dataQ  s    z/TestDataFramePlots.test_scatterplot_object_dataordered
categories)setosa
versicolor	virginica)r  r  r  c                 C   s   t ddgddgddgddgddggd	d
gd}tjg d||d|d< |jjdddd}|j\}|j}tg d}|	 }t
|| tg d}	|j}
t
|
|	 |}dd |j D }tdd t||D sJ d S )Ngffffff@g      @g@r   g      @g	@g@g@lengthrF  r   )r  r  r  r  r  )r  r  Zspeciesr   r@   rR   rS   r   )      ?g      ?g      @r   c                 S   s   g | ]}|  qS r9   get_text)rN  ir9   r9   r:   rP  y  rQ  zLTestDataFramePlots.test_scatterplot_color_by_categorical.<locals>.<listcomp>c                 s   s   | ]\}}||kV  qd S Nr9   )rN  r  jr9   r9   r:   	<genexpr>z  rQ  zKTestDataFramePlots.test_scatterplot_color_by_categorical.<locals>.<genexpr>)r   r   Categoricalr5   r   collectionscolorbarr/   r   Z	get_ticksr   r	  Z_boundariesrc   Zget_ymajorticklabelsallr{   )r7   r  r  r8   rc   Zcolorbar_collectionr  Zexpected_ticksZresult_ticksZexpected_boundariesZresult_boundariesZexpected_yticklabelsZresult_yticklabelsr9   r9   r:   %test_scatterplot_color_by_categorical]  s*     
z8TestDataFramePlots.test_scatterplot_color_by_categorical)rQ   )rS   rR   )rS   rS   c                 C   s2   t g dtg dd}t|jj||d d S )Nr   )r   r   r   r   rQ   )r   r   r  r   r5   r   rm  r9   r9   r:   'test_plot_scatter_with_categorical_data|  s    z:TestDataFramePlots.test_plot_scatter_with_categorical_datazx, y, cr   )r   r@   r   c                 C   sz   t tjdjddddttjd d g dd}|jj	|||d	}|j
d jjd
ks\J |j
d jj dksvJ d S )Nr   r   ri   r  lowhighsizer   r  r   r  ZGreysr   )r   r/   r0   r1   r   r3   r`   ra   r5   r   r  cmapr   r  rc   
get_ylabel)r7   rR   rS   r   r8   rc   r9   r9   r:   test_plot_scatter_with_c  s    z+TestDataFramePlots.test_plot_scatter_with_cc                 C   s   t tjdjddddttjd d g dd}d	}|jj	d
dd|d}|j
d jj|ksbJ |jj	d
dddd}|j
d jd u sJ |jj	dddd}|j
d jd u sJ t|j
dgd d S )Nr   r   ri   r  r  r   r  r   	cubehelixrR   rS   r   )rR   rS   r   colormapF)rR   rS   r   r  r@   redr  r?  Z
facecolors)r   r/   r0   r1   r   r3   r`   ra   r5   r   r  r  r   r  r   )r7   r8   cmrc   r9   r9   r:   test_plot_scatter_with_c_props  s    z1TestDataFramePlots.test_plot_scatter_with_c_propsc                 C   s   t ddgddgd}g d}g d}t||g}|jjdd	|d
}t|jd  | tddg}|jjdd	|dd d S )Nr@   r   rP   r"   r   )r   r   r   r   )r   r   r   r   r   r'   r  r   r   r   Zspring)rR   rS   r   r  )	r   r/   r   r5   r   r   r	  r  Zget_facecolor)r7   r8   Zred_rgbaZ
green_rgbaZ
rgba_arrayrc   Zfloat_arrayr9   r9   r:   test_plot_scatter_with_c_array  s    z1TestDataFramePlots.test_plot_scatter_with_c_arrayc                 C   sV   t tjddd g dd}|jjdddd	}tj|d j|j	d
 
 d d S )Nr   r]   ri   r   r   r   r   r   )rR   rS   r   r   )right)r   r/   r0   r1   r5   r   r   r	  valuesr  Z	get_sizesrb   r9   r9   r:   test_plot_scatter_with_s  s
    z+TestDataFramePlots.test_plot_scatter_with_sc                 C   sX   t tjddd g dd}tj }|jjddd|d	}|j	d
 j
|u sTJ d S )Nr   r]   ri   r   r   r   r   r   )rR   rS   r   normr   )r   r/   r0   r1   r   colorsZLogNormr5   r   r  r  )r7   r8   r  rc   r9   r9   r:   test_plot_scatter_with_norm  s    
z.TestDataFramePlots.test_plot_scatter_with_normc                 C   s   t tjddd g dd}|jjdddd	}|jd
 j}|j	 |j
 f}tjj| }|jD ]}||||ksfJ qfd S )Nr   r]   ri   r   r   r   r   r   r  r   )r   r/   r0   r1   r5   r   r  r  r   minmaxr   r  Z	Normalize)r7   r8   rc   Z	plot_normZcolor_min_maxZdefault_normvaluer9   r9   r:   test_plot_scatter_without_norm  s    
z1TestDataFramePlots.test_plot_scatter_without_normlegendr<   c                 C   sF   t tjddttjd d g dd}t|j	j
fi | d S )Nr   r  r   onetwothreer  r   )r   r/   r0   r1   r2   r3   r`   ra   r   r5   r   rn   r9   r9   r:   test_plot_bar  s    z TestDataFramePlots.test_plot_barc                 C   s>   t tjddttjd d tdd}t	|j
j d S )Nr   )r!      r!   r  r   )r   r/   r0   r1   r2   r3   r`   ra   r|   r   r5   r   r6   r9   r9   r:   test_plot_bar_int_col  s    z(TestDataFramePlots.test_plot_bar_int_colc                 C   sR   t ddgddgd}t|jj}t|dd |jjddd}t|dddd	 d S )
Nr   r@   r  Z   rL   #   r!   rotfontsizerM   
xlabelsize
ylabelsize)r   r   r5   r   r   rb   r9   r9   r:   test_plot_bar_ticks  s
    z&TestDataFramePlots.test_plot_bar_ticksc                 C   sR   t ddgddgd}t|jj}t|dd |jjddd}t|dddd d S )	Nr   r@   r  )yrot7      r  )r  r  r  )r   r   r5   rC  r   rb   r9   r9   r:   test_plot_barh_ticks  s
    z'TestDataFramePlots.test_plot_barh_ticksc                 C   sv   |}|  j}dd |D }t|jj}t| | t|j	
 tdt|d  t|jdt| ksrJ d S )Nc                 S   s   g | ]}t |qS r9   r   rN  r   r9   r9   r:   rP  
  rQ  z3TestDataFramePlots.test_boxplot.<locals>.<listcomp>r@   r   )_get_numeric_datar,   r   r5   boxr   rv   r   r	  ru   rj  r/   r   r   r   r7   hist_dfr8   numeric_colslabelsrc   r9   r9   r:   test_boxplot  s    
zTestDataFramePlots.test_boxplotc                 C   s8   |}|d }|j jdd}t|ddd t|j j d S )Nheight(   r  r   rM   r  )r5   r  r   r   )r7   r  r8   seriesrF   r9   r9   r:   test_boxplot_series  s
    z&TestDataFramePlots.test_boxplot_seriesc                 C   sv   |}t g d}|jj|d}| j}dd |D }t| | t	|j
 | t|jdt| ksrJ d S )N)r@   r   r   )	positionsc                 S   s   g | ]}t |qS r9   r   r  r9   r9   r:   rP     rQ  zDTestDataFramePlots.test_boxplot_series_positions.<locals>.<listcomp>r   )r/   r   r5   r  r  r,   r   rv   r   r	  ru   rj  r   r   )r7   r  r8   r  rc   r  r  r9   r9   r:   test_boxplot_series_positions  s    
z0TestDataFramePlots.test_boxplot_series_positionsc                 C   sj   |}|  j}dd |D }|jjdddd}t|dddd t| | t|jd	t| ksfJ d S )
Nc                 S   s   g | ]}t |qS r9   r   r  r9   r9   r:   rP  (  rQ  z<TestDataFramePlots.test_boxplot_vertical.<locals>.<listcomp>2   r   F)r  r  vertr   rM   r  r  r   )	r  r,   r5   r  r   r   get_yticklabelsr   r   r  r9   r9   r:   test_boxplot_vertical%  s    
z(TestDataFramePlots.test_boxplot_verticalzignore:Attempt:UserWarningc                 C   s   |}|  j}dd |D }t|jjddddd}t|ddd t|d	d
 t||D ]*\}}t|	 |g t
|jdksVJ qVd S )Nc                 S   s   g | ]}t |qS r9   r   r  r9   r9   r:   rP  4  rQ  zETestDataFramePlots.test_boxplot_vertical_subplots.<locals>.<listcomp>TF)r=   r>   r  r   rP   )r@   rP   rA   r   r   r   )r  r,   r   r5   r  r   r   r{   r   r  r   r   )r7   r  r8   r  r  rF   rc   r   r9   r9   r:   test_boxplot_vertical_subplots0  s    
z1TestDataFramePlots.test_boxplot_vertical_subplotsc                 C   sx   |}|  j}dd |D }tg d}|jj|dd}t| | t	|j
 | t|jdt| kstJ d S )Nc                 S   s   g | ]}t |qS r9   r   r  r9   r9   r:   rP  E  rQ  zFTestDataFramePlots.test_boxplot_vertical_positions.<locals>.<listcomp>)rP   r   r   F)r  r  r   )r  r,   r/   r   r5   r  r   r  r   r	  r   rj  r   r   )r7   r  r8   r  r  r  rc   r9   r9   r:   test_boxplot_vertical_positionsB  s    
z2TestDataFramePlots.test_boxplot_vertical_positionsc                 C   sr   t tjddttjd d g dd}d}tj	t
|d |jjdd	 W d    n1 sd0    Y  d S )
Nr   r  r   r  r   z2return_type must be {None, 'axes', 'dict', 'both'}rT   Z
not_a_typereturn_type)r   r/   r0   r1   r2   r3   r`   ra   rV   rW   r   r5   r  rZ   r9   r9   r:    test_boxplot_return_type_invalidL  s    z3TestDataFramePlots.test_boxplot_return_type_invalidr  )dictrF   Zbothc                 C   sJ   t tjddttjd d g dd}|jj	|d}t
|| d S )Nr   r  r   r  r   r  )r   r/   r0   r1   r2   r3   r`   ra   r5   r  r   )r7   r  r8   r   r9   r9   r:   %test_boxplot_return_type_invalid_typeV  s    z8TestDataFramePlots.test_boxplot_return_type_invalid_typec                 C   sZ   t d ttjdd}t|jdd}dd |j	D }t
||d t|d	d
 d S )Nscipyr   ri   r"   kder  c                 S   s   g | ]}t |qS r9   r   r  r9   r9   r:   rP  d  rQ  z2TestDataFramePlots.test_kde_df.<locals>.<listcomp>r  r   rL   )rV   importorskipr   r/   r0   r1   r2   r   r5   r,   r   r   )r7   r8   rc   rf  r9   r9   r:   test_kde_df`  s    
zTestDataFramePlots.test_kde_dfc                 C   sD   t d ttjdd}|jdddd}t|dddd d S )	Nr  r   r    r  r_  rg   )r  r  r  r  )	rV   r  r   r/   r0   r1   r2   r5   r   rb   r9   r9   r:   test_kde_df_roth  s    
z"TestDataFramePlots.test_kde_df_rotc                 C   sD   t d ttjdd}t|jdddd}t	|ddd	 d S )
Nr  r   r    Tr  )r=   r  r>   r"   r?   rA   )
rV   r  r   r/   r0   r1   r2   r   r5   r   rE   r9   r9   r:   test_kde_df_subplotsn  s    
z'TestDataFramePlots.test_kde_df_subplotsc                 C   s@   t d ttjdd}|jdddd}t|dd d S )	Nr  r   r    r  T)r  r   r>   r   r   )	rV   r  r   r/   r0   r1   r2   r5   r   rE   r9   r9   r:   test_kde_df_logyy  s    
z#TestDataFramePlots.test_kde_df_logyc                 C   s@   t d ttjdjdd}tj|jd< t	|j
dd d S )Nr  r   r  r  r   r   r  r  )rV   r  r   r/   r0   r1   uniformr   locr   r5   r6   r9   r9   r:   test_kde_missing_vals  s    
z(TestDataFramePlots.test_kde_missing_valsc                 C   sp   t tjdd}t|jj}dd |jD }t	||d t|jjdddd}t
|dd	d
 t|dd d S )Nr   r  c                 S   s   g | ]}t |qS r9   r   r  r9   r9   r:   rP    rQ  z3TestDataFramePlots.test_hist_df.<locals>.<listcomp>r  T)r=   r>   r   r"   r?   rA   r   r   )r   r/   r0   r1   r2   r   r5   r   r,   r   r   r   )r7   r8   rc   rf  rF   r9   r9   r:   test_hist_df  s    zTestDataFramePlots.test_hist_dfc                 C   s6   t tjdd}|jjdd}t|ddd d S )Nr   r!   r  r  r   r  )r	   r/   r0   r1   r5   r   r   )r7   r  rF   r9   r9   r:   test_hist_df_series  s    z&TestDataFramePlots.test_hist_df_seriesc                    sb   ddl m  ttjdd}|jjdddd} fdd	| D }t	
|d
  d d S )Nr   	Rectangler   r!   Tr"   )
cumulativebinsdensityc                    s   g | ]}t | r|qS r9   r   rN  rR   r  r9   r:   rP    rQ  zMTestDataFramePlots.test_hist_df_series_cumulative_density.<locals>.<listcomp>rH   r   Zmatplotlib.patchesr  r	   r/   r0   r1   r5   r   Zget_childrenr   assert_almost_equalrD  r7   r  rc   Zrectsr9   r  r:   &test_hist_df_series_cumulative_density  s
    z9TestDataFramePlots.test_hist_df_series_cumulative_densityc                    s`   ddl m  ttjdd}|jjddd} fdd	| D }t	
|d
  d d S )Nr   r  r   r!   Tr"   )r  r  c                    s   g | ]}t | r|qS r9   r  r  r  r9   r:   rP    rQ  zETestDataFramePlots.test_hist_df_series_cumulative.<locals>.<listcomp>rS  rh  r  r  r9   r  r:   test_hist_df_series_cumulative  s
    z1TestDataFramePlots.test_hist_df_series_cumulativec                 C   s<   t tjdd}|jjdddd}t|dddd d S )	Nr   r    r  r   
horizontal)r  r  orientationr   r  )r   r/   r0   r1   r2   r5   r   r   rE   r9   r9   r:   test_hist_df_orientation  s    z+TestDataFramePlots.test_hist_df_orientationweights皙?)ri   )shape)ri   r   c                 C   sr   t ttddgtjdd}t|jd|d}t|jdd}dd	 |j	D }d
d	 |j	D }t
|| d S )Nr   r'   r   r   ri   r   )r  r   r  c                 S   s   g | ]}|  qS r9   rc  rN  patchr9   r9   r:   rP    rQ  z8TestDataFramePlots.test_hist_weights.<locals>.<listcomp>c                 S   s   g | ]}d |   qS )r  rc  r  r9   r9   r:   rP    rQ  )r   r  r{   r/   r0   r1   r2   r   r5   r=  r   r  )r7   r   r8   r  r  Zpatch_height_with_weightsZexpected_patch_heightr9   r9   r:   test_hist_weights  s    z$TestDataFramePlots.test_hist_weightsc           
      C   s   t dd |D }t dd |D }t dd |D }t dd |D }	|d urhtj||dd |d urtj||dd |d urtj||dd |d urtj|	|dd d S )Nc                 S   s   g | ]}|  qS r9   rL  rM  r9   r9   r:   rP    rQ  z7TestDataFramePlots._check_box_coord.<locals>.<listcomp>c                 S   s   g | ]}|  qS r9   rc  rM  r9   r9   r:   rP    rQ  c                 S   s   g | ]}|  qS r9   r[  rM  r9   r9   r:   rP    rQ  c                 S   s   g | ]}|  qS r9   )rB  rM  r9   r9   r:   rP    rQ  F)Zcheck_dtype)r/   r   r   r	  )
r7   r=  
expected_y
expected_h
expected_x
expected_wZresult_yZresult_heightZresult_xZresult_widthr9   r9   r:   _check_box_coord  s    z#TestDataFramePlots._check_box_coordr"  r   r!   	   r   r   r   r   r   r   r   r   r   r   r   r  r!   ra  r   rP   rg   )rP   r!   r  r   r   r   )r   rP   r   r   r   r   )r   r   r   rP   r  r!   c                 C   s  t |}|jjdd}| j|jd d tg dtg dd | j|jdd tg dtg dd | j|jdd  tg dtg dd |jjdd	d
}| j|jd d tg dtg dd | j|jdd tg dtg dd | j|jdd  tg dtg dd |jjdd	d	d}| j|d jtg dtg dd | j|d jtg dtg dd | j|d jtg dtg dd |jjddd}| j|jd d tg dtg dd | j|jdd tg dtg dd | j|jdd  tg dtg dd |jjdd	dd}| j|jd d tg dtg dd | j|jdd tg dtg dd | j|jdd  tg dtg dd |jjdd	d	dd}| j|d jtg dtg dd | j|d jtg dtg dd | j|d jtg dtg dd d S )Nrg   )r  )r   r   r   r   r   r  )r  r  r!   r  r  T)r  r  )      r   r     )r  r  r>   r   r@   r   r  )r  r  )r	  r
  )r  r  r  )r  r  r>   r  )r   r5   r   r  r=  r/   r   )r7   r"  r8   rc   rF   r9   r9   r:   test_hist_df_coord  s    z%TestDataFramePlots.test_hist_df_coordc                 C   s,   t tjdd }t|jdd d S )Nr   r  Tr  )r   r/   r0   r1   r2   cumsumr   r5   r6   r9   r9   r:   test_plot_int_columns_  s    z(TestDataFramePlots.test_plot_int_columnsmarkers^+o)r  r  r  c                 C   s   dd l m} | }|  |d ttjd	d}|j
|d}t| d t| D ]\}}| || ks`J q`d S )Nr   o   r   r]   )style)matplotlib.pyplotr   gcfZclfadd_subplotr   r/   r0   r1   r2   r5   	enumerater   r   Z
get_marker)r7   r  pltr9  r8   rc   r  rY   r9   r9   r:   test_style_by_columnc  s    

 z'TestDataFramePlots.test_style_by_columnc                 C   sP   t ddg}| }| d u s$J |jdd}|  d  dksLJ d S )Nr@   r   Tr  r    )r	   r5   
get_legend	get_textsr  )r7   r   rc   r9   r9   r:   test_line_label_nonew  s
    z'TestDataFramePlots.test_line_label_nonezprops, expected))ZboxpropsZboxes)ZwhiskerpropsZwhiskers)ZcappropsZcaps)ZmedianpropsZmediansc                 C   sP   t dd dD }|ddii}|jjf ddi|}|| d  dksLJ d S )	Nc                 S   s    i | ]}|t jd dqS r  )r/   r0   r1   )rN  kr9   r9   r:   
<dictcomp>  rQ  zHTestDataFramePlots.test_specified_props_kwd_plot_box.<locals>.<dictcomp>ABCcolorZC1r  r  r   )r   r5   r  	get_color)r7   propsrf  r8   Zkwdr   r9   r9   r:   !test_specified_props_kwd_plot_box  s    z4TestDataFramePlots.test_specified_props_kwd_plot_boxc           	      C   s   t dddt dddt dddg}g d}tt||dgd}| }|jd	  }t|tj|t	d
 |jd	 
 }t|t| |j }dd |D }t|jsJ dd |D }tj|ddjsJ d S )N  r!   r@   r  r   )r   r   r   testr   r   r$   c                 S   s   g | ]}|  d  qS )r   )Zget_positionr  r9   r9   r:   rP    rQ  z8TestDataFramePlots.test_unordered_ts.<locals>.<listcomp>c                 S   s   g | ]}|  qS r9   r  r  r9   r9   r:   rP    rQ  z%Y-%m-%dr   )r   r   r/   r   r5   r   r   r   r	  r4   r  ru   Zget_ticklabelsr   Zis_monotonic_increasingr   r   )	r7   r-   r  r8   rc   rh   ZydataZxlocsZxlabelsr9   r9   r:   test_unordered_ts  s"    "
z$TestDataFramePlots.test_unordered_tsc                 C   s8   t d tdg di}|j|d t|j|  d S Nr  rR   r   r  rV   r  r   r5   r   r7   r  r8   r9   r9   r:   test_kind_both_ways  s    
z&TestDataFramePlots.test_kind_both_waysc                 C   s@   t d tdg di}|jdd|d t|j|dd d S r1  r2  r3  r9   r9   r:   test_kind_both_ways_x_y  s    
z*TestDataFramePlots.test_kind_both_ways_x_yc                 C   sN   t td}d}tjt|d |j|d W d    n1 s@0    Y  d S )Nabcdno numeric data to plotrT   r  )r   r3   rV   rW   rq  r5   r7   r  r8   r[   r9   r9   r:   test_all_invalid_plot_data  s    z-TestDataFramePlots.test_all_invalid_plot_datac                 C   s|   t tjddtd}d|tjd|jd dk< d}tjt	|d |j
|d	 W d    n1 sn0    Y  d S )
Nr   r!   r   r$   r   r   r  r7  rT   r  )r   r/   r0   r1   r2   r4   r  rV   rW   rq  r5   r8  r9   r9   r:   (test_partially_invalid_plot_data_numeric  s     z;TestDataFramePlots.test_partially_invalid_plot_data_numericc                 C   sX   t tjdd}d}tjt|d |jdd W d    n1 sJ0    Y  d S )Nr   r:  z*invalid_plot_kind is not a valid plot kindrT   Zinvalid_plot_kindr  )	r   r/   r0   r1   r2   rV   rW   r   r5   rZ   r9   r9   r:   test_invalid_kind  s    z$TestDataFramePlots.test_invalid_kindzx,y,lblr   r   r   c                 C   s^   t ddgddgddgd}tjtdd	  |j|||d
 W d    n1 sP0    Y  d S )Nr@   r   rP   r"   rg   r   ra  x must be a label or positionrT   rR   rS   r   r   rV   rW   r   r5   )r7   rR   rS   lblr8   r9   r9   r:   test_invalid_xy_args  s    	z'TestDataFramePlots.test_invalid_xy_argsc                 C   sf   t ddgddgddgd}d}tjt|d	$ |jd
ddgdd W d    n1 sX0    Y  d S )Nr@   r   rP   r"   rg   r   ra  z.label should be list-like and same length as yrT   r   r'   r   Z	bad_labelr>  r?  rZ   r9   r9   r:   test_bad_label  s    z!TestDataFramePlots.test_bad_labelzx,yr   c                 C   s\   t g dg dgtdd}tjtdd |j||d W d    n1 sN0    Y  d S )N)r@   rP   rg   )r   r"   r   ZAABr   r=  rT   rQ   )r   r3   rV   rW   r   r5   rm  r9   r9   r:   test_invalid_xy_args_dup_cols  s    z0TestDataFramePlots.test_invalid_xy_args_dup_colszx,y,lbl,colorsr  bluer   Zbokehcythongreenyellowc                 C   sj   t ddgddgddgd}t|jd||d	 |j||||d
}t|jt|ksVJ t| |d d S )Nr@   r   rP   r"   rg   r   ra  r   r>  )rR   rS   r   r*  Z
linecolors)r   r   r5   r   r   r   r   )r7   rR   rS   r@  r  r8   rc   r9   r9   r:   test_y_listlike  s
    
z"TestDataFramePlots.test_y_listlikezx,y,colnamesc                 C   s0   t ddgddgd}||_t|j||d d S )Nr@   r   rP   r"   r   rQ   )r   r,   r   r5   )r7   rR   rS   Zcolnamesr8   r9   r9   r:   test_xy_args_integer  s    z'TestDataFramePlots.test_xy_args_integerc                 C   sr   t tjdjddtjdjddtdtjdjdd d}|jjdddd}t|j	d	ksnJ d S )
Nr   r_  r  ra  r   r'   r!   )rR   rS   Zgridsizer@   
r   r/   r0   r1   r  r   r5   r   r   r  rb   r9   r9   r:   test_hexbin_basic  s    z$TestDataFramePlots.test_hexbin_basicc                 C   s   t tjdjddtjdjddtdtjdjdd d}|jjdddd}t|d	 j	j
dkstJ t|d
dd d S )Nr   r_  r  ra  r   r'   T)rR   rS   r>   r   r@   r   rA   )r   r/   r0   r1   r  r   r5   r   r   figurerF   r   rE   r9   r9   r:   test_hexbin_basic_subplots  s    z-TestDataFramePlots.test_hexbin_basic_subplotsreduce_Cc                 C   st   t tjdjddtjdjddtdtjdjdd d}|jjddd|d}t|j	d	kspJ d S )
Nr   r_  r  ra  r   r'   r   )rR   rS   r   Zreduce_C_functionr@   rK  )r7   rO  r8   rc   r9   r9   r:   test_hexbin_with_c  s    z%TestDataFramePlots.test_hexbin_with_czkwargs, expectedZBuGnr  r  r  ZYlGnc                 C   s|   t tjdjddtjdjddtdtjdjdd d}|jjf ddd|}|jd j	j
|ksxJ d S )	Nr   r_  r  ra  r   r'   rQ   r   )r   r/   r0   r1   r  r   r5   r   r  r  r   )r7   re   rf  r8   rc   r9   r9   r:   test_hexbin_cmap+  s    	z#TestDataFramePlots.test_hexbin_cmapc                 C   sd   t tjddg dg dd}d}tjt|d |j  W d    n1 sV0    Y  d S )Nr   rg   rP   XYZr   r   r   der+   z/pie requires either y column or 'subplots=True'rT   )	r   r/   r0   r1   rV   rW   r   r5   r   rZ   r9   r9   r:   test_pie_df_err>  s    z"TestDataFramePlots.test_pie_df_errrU  c                 C   sF   t tjddg dg dd}t|jj|d}t|j|j	 d S )Nr   rR  rS  rW  r+   r   )
r   r/   r0   r1   r   r5   r   r   textsr-   )r7   rS   r8   rc   r9   r9   r:   test_pie_dfH  s    zTestDataFramePlots.test_pie_dfc                 C   s   t tjddg dg dd}t|jjddd}t|t|jksLJ |D ]}t	|j
|j qPt||jD ]\}}| |kspJ qpd S )Nr   rR  rS  rW  r+   Tr<   )r   r/   r0   r1   r   r5   r   r   r,   r   r[  r-   r{   r  )r7   r8   rF   rc   ylabelr9   r9   r:   test_pie_df_subplotsR  s    z'TestDataFramePlots.test_pie_df_subplotsc                 C   s   t tjddg dg dd}g d}g d}t|jjdd||d	}t|t|jks`J |D ]}t	|j
| t|j|d
 qdd S )Nr   rR  rS  rW  r+   r   )r?  gr   r   mT)r=   r>   r  r  r  )r   r/   r0   r1   r   r5   r   r   r,   r   r[  r   r=  )r7   r8   r  Z
color_argsrF   rc   r9   r9   r:   test_pie_df_labels_colorsc  s$    z,TestDataFramePlots.test_pie_df_labels_colorsc                 C   s  t tjdd}tdD ]}tj|j||f< qtjj	dd\}}ddi}t
d * |jjf d|dd| W d    n1 s0    Y  g d}t|D ]r\}}t|}d	||< d
d |jD }	|	|ksJ dd |  D }
|d | ||d d   }|
|ksJ qd S )Nr   )r"   r"   r"   )Zncols	normalizeT)r>   rc   r  )0123r#  c                 S   s   g | ]}|  qS r9   r  r  r9   r9   r:   rP    rQ  z6TestDataFramePlots.test_pie_df_nan.<locals>.<listcomp>c                 S   s   g | ]}|  qS r9   r  r  r9   r9   r:   rP    rQ  r@   )r   r/   r0   r1   r|   r   Zilocr   r   r>   r   r   r5   r   r   r3   r[  r$  r%  )r7   r8   r  r   rF   re   Zbase_expectedrc   rf  r   Zresult_labelsexpected_labelsr9   r9   r:   test_pie_df_nanx  s     8z"TestDataFramePlots.test_pie_df_nanr   )r   r   r   c                 C   sp   t dt dddd}t|}t dd t dd d}t|}t|jfd|i|}t|ddd	 d S )
Nr{  r   rH   rQ   皙?皙?yerrr   xerrrk  r/   r   r   onesr   r5   r   )r7   re   rX  r8   d_errdf_errrc   r9   r9   r:   test_errorbar_plot  s    
z%TestDataFramePlots.test_errorbar_plotc                 C   sr   t dt dddd}t|}t dd t dd d}t|}t|d j||dd	d
}t|ddd d S )Nr{  r   rH   rQ   ri  rj  r@   r   T)rk  rm  r  r   r   rl  rn  )r7   rX  r8   rp  rq  rc   r9   r9   r:   test_errorbar_plot_bar  s    z)TestDataFramePlots.test_errorbar_plot_barc                 C   sv   t dt dddd}t|}t|d jt dd d}t|ddd	 t|jt d
d d}t|ddd	 d S )Nr{  r   rH   rQ   rS   rj  rk  r@   rl  )r   r{  r   )r/   r   r   r   r5   ro  r   r7   rX  r8   rc   r9   r9   r:   test_errorbar_plot_yerr_array  s    z0TestDataFramePlots.test_errorbar_plot_yerr_arrayrk  u   誤差c                 C   st   t dt dddd}t|}t dd ||< t|j|d}t|ddd t|jd	d
|d}t|ddd d S )Nr{  r   rH   rQ   ri  rt  r   rl  rS   rR   )rS   rR   rk  r@   rn  )r7   rk  rX  r8   rc   r9   r9   r:   test_errorbar_plot_column_name  s    z1TestDataFramePlots.test_errorbar_plot_column_namec                 C   sj   t dt dddd}t|}tt* |jt jd	dd W d    n1 s\0    Y  d S )Nr{  r   rH   rQ   r   r  rt  )
r/   r   r   r   external_error_raisedr   r5   r0   r1   r2   r7   rX  r8   r9   r9   r:   &test_errorbar_plot_external_valueerror  s    z9TestDataFramePlots.test_errorbar_plot_external_valueerrorc                 C   sv   t dt dddd}t|}tdgd dgd d}tt |j|d W d    n1 sh0    Y  d S )Nr{  r   rH   rQ   zzzrt  )r/   r   r   r   rx  rq  r5   )r7   rX  r8   rq  r9   r9   r:   %test_errorbar_plot_external_typeerror  s
    z8TestDataFramePlots.test_errorbar_plot_external_typeerror)rY   r   rC  y_errr{  ri  )r   rj  c                 C   s@   t tdtdddd}t|j||d}t|ddd d S )Nr{  r   rH   rQ   rk  r  r   rl  r   r/   r   r   r5   r   )r7   r  r}  r8   rc   r9   r9   r:   !test_errorbar_plot_different_yerr  s    
z4TestDataFramePlots.test_errorbar_plot_different_yerrzy_err, x_err)ri  ri  c                 C   sB   t tdtdddd}t|j|||d}t|ddd d S )Nr{  r   rH   rQ   )rk  rm  r  r   rl  r  )r7   r  r}  Zx_errr8   rc   r9   r9   r:   &test_errorbar_plot_different_yerr_xerr  s    z9TestDataFramePlots.test_errorbar_plot_different_yerr_xerrc                 C   sh   t tdtdddd}t tdd tdd d}t|jd||d|d}t|d	d	d
 d S )Nr{  r   rH   rQ   ri  rj  T)r=   rk  rm  r>   r  r@   rl  )r   r/   r   ro  r   r5   r   )r7   r  r8   rq  rF   r9   r9   r:   /test_errorbar_plot_different_yerr_xerr_subplots  s    "zBTestDataFramePlots.test_errorbar_plot_different_yerr_xerr_subplotszIterator is consumed)rO   rW   c                 C   sN   t dt dddd}t|}t|jtdt|d}t|ddd d S )	Nr{  r   rH   rQ   r  rt  r   rl  )	r/   r   r   r   r5   	itertoolsrepeatr   r   ru  r9   r9   r:   test_errorbar_plot_iterator  s    z.TestDataFramePlots.test_errorbar_plot_iteratorc                 C   sv   t ttjdd}t ttjdd}t|j|d}t|ddd t|jddd}t|ddd d S )Nr   r:  rt  r   rl  r@   )rS   rk  	r   r/   absr0   r1   r2   r   r5   r   r7   r8   rq  rc   r9   r9   r:   'test_errorbar_with_integer_column_names  s    z:TestDataFramePlots.test_errorbar_with_integer_column_namesc                 C   sb   t ttjdd}t ttjddddgd}t|j||d}t|ddd d S )Nr   r]   r:  r   r   r~  rl  r  )r7   r  r8   rq  rc   r9   r9   r:   'test_errorbar_with_partial_columns_kind  s    z:TestDataFramePlots.test_errorbar_with_partial_columns_kindc                 C   s   t ttjdd}t ttjddddgd}tdddd	}|j|d
d |j|d
d t|j	|dd}t
|ddd d S )Nr   r]   r:  r   r   1/1/2000r!   MEr(   T)ZinplacerY   r~  rl  )r   r/   r  r0   r1   r2   r   r   r   r5   r   )r7   r8   rq  ixrc   r9   r9   r:   &test_errorbar_with_partial_columns_dti#  s    z9TestDataFramePlots.test_errorbar_with_partial_columns_dtierr_boxc                 C   s   | S r  r9   r   r9   r9   r:   <lambda>0  rQ  zTestDataFramePlots.<lambda>c                 C   sd   t dt dddd}t|}|t dd t dd d}t|j|d}t|dd	d
 d S )Nr{  r   rH   rQ   ri  rj  )rR   r   rt  r@   rl  rn  )r7   r  rX  r8   errrc   r9   r9   r:   &test_errorbar_with_partial_columns_box/  s
    "z9TestDataFramePlots.test_errorbar_with_partial_columns_boxc           	      C   s"  t dt dddd}t dd t dd d}tddd	d
}t||d}t||d}t|j||d}t|ddd t|j||d}t|ddd t|jd|d |d}t|ddd t|jdd|d}t|ddd t|j||d}t|ddd t|jd||dd}t|ddd d S )Nr{  r   rH   rQ   ri  rj  r  z1/1/2001r  )r*   r^   r~  r   rl  rS   rR   )rS   rk  r  r@   T)r=   r  rk  r>   )r/   r   ro  r   r   r   r5   r   )	r7   r  rX  rp  r  ZtdfZtdf_errrc   rF   r9   r9   r:   test_errorbar_timeseries8  s.    z+TestDataFramePlots.test_errorbar_timeseriesc                 C   s   t jdd}tt dddj}|j||d d}|jd 	 d j
d d df }|dd d df t d	dg }t|| td
}tjt|d |j|jd W d    n1 s0    Y  d S )Nr   )rP   r   rg   r  rP   rg   )rk  rm  r@   r   rH   zCAsymmetrical error bars should be provided with the shape (3, 2, 5)rT   rt  )r/   r0   r1   r   r   ZreshapeTr5   r  	get_pathsZverticesr   r   r  ro  rp  rV   rW   r   )r7   r  r8   rc   Zyerr_0_0Zexpected_0_0r[   r9   r9   r:   test_errorbar_asymmetricalZ  s      z-TestDataFramePlots.test_errorbar_asymmetricalc                 C   s   t tjddttjd d d}t|jdd t|j|d t	
d J | }t|jdksjJ t||j t|jdksJ W d    n1 s0    Y  d S )	Nr   r]   r!   r^   T)tabler   r@   )r   r/   r0   r1   r3   r`   ra   r   r5   r   r   r   Ztablesr   r  r  rb   r9   r9   r:   
test_tablel  s    zTestDataFramePlots.test_tablec                 C   s   t ttjddtdddgd}t ttjddd tdddgd}t|jj	ddd}t
|ddd	 t|jj	dd|d
}t
|ddd	 t|jj	dd|d}t
|ddd	 t|jj	dd||d}t
|ddd	 d S )Nr   )rg   r   rg   rR   rS   r   rQ   r   rl  )rR   rS   rm  r@   )rR   rS   rk  )rR   rS   rm  rk  )r   r/   r  r0   r1   r2   r|   r   r5   r   r   r  r9   r9   r:   test_errorbar_scatter{  s$    z(TestDataFramePlots.test_errorbar_scatterc                    s   d fdd	}t ttjddg dd}|jjdd	d
ddd t ddd | j	ddd | j	ddd |jjdd	ddd t ddd | j	ddd d S )Nhas_xerrc                    sv   g }t  fddjD }|D ]"}t|r8|| q || q fdd|D }t|t|gt| d d S )Nc                 3   s    | ]}t | d r|jV  qdS )FN)r   r   r  has_errr9   r:   r    rQ  z`TestDataFramePlots.test_errorbar_scatter_color.<locals>._check_errorbar_color.<locals>.<genexpr>c                    s   g | ]}| j v r|qS r9   )r  r  rc   r9   r:   rP    rQ  zaTestDataFramePlots.test_errorbar_scatter_color.<locals>._check_errorbar_color.<locals>.<listcomp>rH  )	next
containersr   extendappendr   r/   r   r   )r  rf  r  r   ZerrselZ	err_linesr  r  r:   _check_errorbar_color  s    zMTestDataFramePlots.test_errorbar_scatter_color.<locals>._check_errorbar_colorr   )r!   rg   rW  r   r   r   rX  rY  r  )rR   rS   rm  rk  r   r@   rl  r  Zhas_yerrrF  )rR   rS   rk  r*  r   )r  )
r   r/   r  r0   r1   r2   r5   r   r   r  )r7   r  r8   r9   r  r:   test_errorbar_scatter_color  s    z.TestDataFramePlots.test_errorbar_scatter_colorc                 C   sZ   t g ddd}tjttfdd" |jdddd	d
 W d    n1 sL0    Y  d S )Nr   r"   r  z'unknown' is not arT   r   r   unknownr   )rR   rS   r  r  )r   rV   rW   r   KeyErrorr5   r6   r9   r9   r:   test_scatter_unknown_colormap  s    z0TestDataFramePlots.test_scatter_unknown_colormapc                 C   s   dd l m} |d t \}}tg dg dg dg dd}dd }|D ]}|jddd	|d
d qN||  || |d t \}}t	t
  |jd
|d
d}W d    n1 s0    Y  || d S )Nr   r  r@   r   rP   r"   rg   r   r   r   r   rX  c                 S   s   | D ]&}t |jdksJ t| dd q| d | d fD ](}t| dd t|jdddd q<| d | d fD ](}t| dd t|jdddd qvd S )	Nr@   Trq   r   r   Frs   rP   )r   r   r   r  rv   rF   rc   r9   r9   r:   _check  s    z5TestDataFramePlots.test_sharex_and_ax.<locals>._checkr   r   rl   T)rR   rS   rl   rc   sharex)r>   rc   r  )r  r   close_generate_4_axes_via_gridspecr   r5   tight_layoutr  r   r   r   r7   r!  gsrF   r8   r  rc   r9   r9   r:   test_sharex_and_ax  s(    

	

.z%TestDataFramePlots.test_sharex_and_axc                 C   s   dd l m} tg dg dg dg dd}t \}}|D ]}|jddd|d q<||  |D ]J}t|jdks|J t	|
 d	d
 t	| d	d
 t	|jd	dd	d
 qfd S Nr   r  r  r   r   rl   )rR   rS   rl   rc   r@   Trq   rs   r  r   r   r  r5   r  r  r   r   r   r  rv   r7   r!  r8   r  rF   rc   r9   r9   r:   test_sharex_false_and_ax  s"    
z+TestDataFramePlots.test_sharex_false_and_axc                 C   s   dd l m} t \}}tg dg dg dg dd}dd }|D ]}|jddd|d	d
 qD||  || |d t \}}t	t
  |jd	|d	d}W d    n1 s0    Y  ||  || d S )Nr   r  r  c                 S   s   | D ]:}t |jdksJ t| dd t|jdddd q| d | d fD ]}t| dd qP| d | d fD ]}t| dd qvd S )	Nr@   Trq   rs   r   r   rP   F)r   r   r   rv   r  r  r9   r9   r:   r    s    z5TestDataFramePlots.test_sharey_and_ax.<locals>._checkr   r   rl   T)rR   rS   rl   rc   r8  r  )r>   rc   r8  )r  r   r  r   r5   r  r  r  r   r   r   r  r9   r9   r:   test_sharey_and_ax  s(    
	


.z%TestDataFramePlots.test_sharey_and_axc                 C   s   dd l m} tg dg dg dg dd}t \}}|D ]}|jddd|d q<||  |D ]J}t|jdks|J t	|
 d	d
 t	| d	d
 t	|jd	dd	d
 qfd S r  r  r  r9   r9   r:   test_sharey_and_ax_tight  s"    
z+TestDataFramePlots.test_sharey_and_ax_tightc                 C   s  t d i }|dv rlttjdjddtjdjddtdtjdjdd d}ddd	}nr|d
krttjddt	t
dtdtddddd }n2ttjddt	t
dtdtddddd}t|jf d|i|}td t  | du sJ dS )z3Check that every plot type gets properly collected.r  )r   r   r   r   r_  r  ra  r   r'   rQ   r  r    r#   r$   r&   r!   r(   r+   r  r  N)rV   r  r   r/   r0   r1   r  r   r2   r   r3   r4   r   r  weakrefrefr5   r!  r  gcZcollect)r7   r  argsr8   r  r9   r9   r:   test_memory_leak3  s2    

z#TestDataFramePlots.test_memory_leakc           	         s  ddl m  dd lm ttjddt	dddd}t
tjdd|jtd	d
} fdd} fdd}| | fD ]\}}|j|d}t|jdksJ |j|d}t|jdksJ ||fD ]8}t| dd t| dd t|jdddd qЈd q| | fD ]\}}|jd||gd}t|jdksPJ t|jdksdJ |D ]:}t| dd t| dd t|jdddd qhd q"| \}}tt& |jd||gddd}W d    n1 s0    Y  t|d jdksJ t|d jdks.J ||fD ]}t| dd q6t|d  dd t|d jdddd t|d  dd t|d jdddd d | \}}tt& |jd||gddd}W d    n1 s0    Y  t|d jdksJ t|d jdks,J t|d  dd t|d  dd ||fD ]*}t| dd t|jdddd q\d d S )Nr   gridspecr   r!   r  r)   r^   r:  ABr   c                     sL     dd}  }|| d dd d f }|| dd d f }||fS )NrP   r@   r   GridSpecrM  r  r  r9  r  r  r  r!  r9   r:   _get_vertical_gridh  s
    zSTestDataFramePlots.test_df_gridspec_patterns_vert_horiz.<locals>._get_vertical_gridc                     sL     dd}  }|| d d d df }|| d d df }||fS )Nr@   rP   r   r  r  r  r9   r:   _get_horizontal_grido  s
    zUTestDataFramePlots.test_df_gridspec_patterns_vert_horiz.<locals>._get_horizontal_gridr  r@   Trq   rs   r  r   r>   rc   r  r8  Fr   r  r  r   r	   r/   r0   r1   r2   r   r   r-   r3   r5   r   r   r   r  rv   r  r   r   r   )	r7   tsr8   r  r  r  r  rc   rF   r9   r  r:   $test_df_gridspec_patterns_vert_horizX  sn    

6

6z7TestDataFramePlots.test_df_gridspec_patterns_vert_horizc                    s  ddl m  dd lm ttjddt	dddd} fdd	}| }t
tjdd
|jtdd}|jd|d}|D ]J}t|jdksJ t| dd t| dd t|jdddd qd | }tt" |jd|ddd}W d    n1 s0    Y  |D ]}t|jdks J q |d |d fD ]}t| dd qL|d |d fD ]}t| dd qt|d |d fD ]*}t| dd t|jdddd q|d |d fD ]*}t| dd t|jdddd q؈d d S )Nr   r  r   r!   r  r  r^   c                     st     dd}  }|| d dd df }|| d ddf }|| dd df }|| d }||||fS )NrP   r   rI   r  )r  r9  r  r  Zax3Zax4r  r9   r:   _get_boxed_grid  s    zKTestDataFramePlots.test_df_gridspec_patterns_boxed.<locals>._get_boxed_gridr    r#   r   Tr   r@   rq   rs   r  r  rP   Fr  )r7   r  r  rF   r8   rc   r9   r  r:   test_df_gridspec_patterns_boxed  sH    
	
2z2TestDataFramePlots.test_df_gridspec_patterns_boxedc                 C   s.   t tg dg ddtjjdddd d S )Nr   r  r  r   r   rQ   )kws)r   r   r   PlotAccessorZ_dataframe_kinds)r7   r9   r9   r:   test_df_grid_settings  s
    z(TestDataFramePlots.test_df_grid_settingsc                 C   s>   t j \}}|g d ttjddj|d d S )N)ri  ri  ri  ri  r   r!   r  )	r   r   r>   add_axesr	   r/   r0   r1   r5   )r7   r9  rc   r9   r9   r:   test_plain_axes  s    z"TestDataFramePlots.test_plain_axesc                 C   sX   t tjddtjddd}tj }|d}|j	d|ddddd	 d S )
Nr   r   r  )r   r   r@   r@   r   r   r   Zhsv)r  rc   rR   rS   r   r  )
r   r/   r0   r1   r2   r   r   rM  r  r5   )r7   r8   r9  rc   r9   r9   r:   test_plain_axes_df  s    

z%TestDataFramePlots.test_plain_axes_dfc                 C   sr   t j \}}ddlm} ||}|jdddd}ttj	ddj
|d	 ttj	ddj
|d	 d S )
Nr   )make_axes_locatabler  z5%g?)r  padr   r!   r  )r   r   r>   Zmpl_toolkits.axes_grid1r  Zappend_axesr	   r/   r0   r1   r5   )r7   r9  rc   r  dividerZcaxr9   r9   r:   #test_plain_axes_make_axes_locatable  s    z6TestDataFramePlots.test_plain_axes_make_axes_locatablec                 C   sj   t j \}}ddlm} ||dddd}ttjddj	|d	 ttjddj	|d	 d S )
Nr   )
inset_axesz30%r   rP   )rF  r  r  r   r!   r  )
r   r   r>   Z%mpl_toolkits.axes_grid1.inset_locatorr  r	   r/   r0   r1   r5   )r7   r9  rc   r  Ziaxr9   r9   r:   test_plain_axes_make_inset_axes	  s
    z2TestDataFramePlots.test_plain_axes_make_inset_axesmethod)rY   rC  r   c                 C   sv   t tjddtddjdd djdd d	}d
}ddg}||dd}t|j|f i |}t	|j
|d d S )Nr   )r  r   r  r   c                 S   s
   | j  S r  )r'   r  r8   r9   r9   r:   r  	  rQ  zBTestDataFramePlots.test_secondary_axis_font_size.<locals>.<lambda>r   c                 S   s
   | j d S )Ng?r  r  r9   r9   r:   r  	  rQ  )r   r_  r   r   T)r.  r  Z
mark_right)rF   r  )r   r/   r0   r1   r2   r3   Zassignr   r5   r   r1  )r7   r  r8   r  r  re   rc   r9   r9   r:   test_secondary_axis_font_size	  s    z0TestDataFramePlots.test_secondary_axis_font_sizec                 C   s   t g dg dg dd}|jjdd}|dd d	d
 | D }tt|| }|d dksjJ |d dkszJ |d dksJ d S )N)rP   r   rP   )r_  *      )MondayTuesday	Wednesday)ZsalesZvisitsdayr  r   rH   rP   c                 S   s   g | ]}|  qS r9   r  rN  tr9   r9   r:   rP  ,	  rQ  zATestDataFramePlots.test_x_string_values_ticks.<locals>.<listcomp>r  r   r  r   r  r   )r   r5   r  set_xlimrv   r  r{   
get_xticks)r7   r8   rc   xticklabelslabels_positionr9   r9   r:   test_x_string_values_ticks 	  s    z-TestDataFramePlots.test_x_string_values_ticksc                 C   s   t ddgddgg}ttjddddg|d}| }|d	d
 dd |	 D }t
t|| }|d dks~J |d dksJ |d dksJ |d dksJ d S )Nr.  i  r@   r   r7  r   r'   r+   rH   r"   c                 S   s   g | ]}|  qS r9   r  r  r9   r9   r:   rP  >	  rQ  zETestDataFramePlots.test_x_multiindex_values_ticks.<locals>.<listcomp>z	(2012, 1)r   z	(2012, 2)r   z	(2013, 1)r   z	(2013, 2)r   )r   Zfrom_productr   r/   r0   r1   r2   r5   r  rv   r  r{   r  )r7   r-   r8   rc   r  r  r9   r9   r:   test_x_multiindex_values_ticks3	  s    z1TestDataFramePlots.test_x_multiindex_values_ticksc                 C   sL   t ddgddgd}|j|d}| }|d dk s8J |d dksHJ d S )Nr   r"   r@   r^   r  r   )r   r5   r   )r7   r  r8   rc   xlimsr9   r9   r:   test_xlim_plot_lineF	  s
    z&TestDataFramePlots.test_xlim_plot_linec                 C   s   t j \}}g d}tg dg dg dg dd|d}|g d jj|d	d
 |dg j|dd | }|d dk sJ |d dksJ dd | D }||ksJ d S )N)Zk1Zk2Zk3Zk4)i  r     r   )i  ix  r   i  )r  r  i@  i  )r@   rP   r"   rP   )s1s2s3r.  r^   )r  r  r  F)rc   r  r.  T)rc   r.  r   r@   rP   c                 S   s   g | ]}|  qS r9   r  r  r9   r9   r:   rP  g	  rQ  zWTestDataFramePlots.test_xlim_plot_line_correctly_in_mixed_plot_type.<locals>.<listcomp>)r   r   r>   r   r5   r   r   rv   )r7   r9  rc   Zindexesr8   r  r  r9   r9   r:   0test_xlim_plot_line_correctly_in_mixed_plot_typeP	  s"    	zCTestDataFramePlots.test_xlim_plot_line_correctly_in_mixed_plot_typec                 C   sl   t dgtd}|jsJ | }t| dks4J | d }t| dksTJ t| dkshJ d S )NZfoo)r,   r%   r@   r   )r   intemptyr5   r   r   r   r  )r7   r8   rc   rY   r9   r9   r:   test_plot_no_rowsj	  s    
z$TestDataFramePlots.test_plot_no_rowsc                 C   sF   t g d}tjtdd |  W d    n1 s80    Y  d S )Nr   r7  rT   )r   rV   rW   rq  r5   r6   r9   r9   r:   test_plot_no_numeric_datat	  s    z,TestDataFramePlots.test_plot_no_numeric_data)rY   r   rC  r   r  r  r  r   c                 C   s   t d tdtdd tdd tdtdd}t|}|jddg|d}t|dksjJ d	d
gddgdgf}t||D ]:\}}|dkrt||d |dkrt|j	t|ksJ qd S )Nr  r!   r@   rW  )r   rY  )r   rX  r>   r  rP   r   rY  r   rX  r   r   r  rY   )
rV   r  r/   r   r   r5   r   r{   r   r   )r7   r  rX  r8   rF   rg  rc   r  r9   r9   r:   test_group_subploty	  s     
z%TestDataFramePlots.test_group_subplotc                 C   sP   t td}d}tjt|d |jdgd W d    n1 sB0    Y  d S )Nr@   z!An iterable subplots for a SeriesrT   r   r>   )r	   r|   rV   rW   NotImplementedErrorr5   )r7   Zserr[   r9   r9   r:   (test_group_subplot_series_notimplemented	  s    z;TestDataFramePlots.test_group_subplot_series_notimplementedc                 C   s`   t tdtddgd}d}tjt|d |jdgd W d    n1 sR0    Y  d S )Nr   rz  rl  r   z6An iterable subplots for a DataFrame with a MultiIndexrT   r  )	r   r/   eyer   r}   rV   rW   r  r5   rZ   r9   r9   r:   ,test_group_subplot_multiindex_notimplemented	  s    z?TestDataFramePlots.test_group_subplot_multiindex_notimplementedc                 C   sZ   t tdddgd}d}tjt|d |jdgd W d    n1 sL0    Y  d S )Nr   r   r   z4An iterable subplots for a DataFrame with non-uniquerT   r  r  )r   r/   r  rV   rW   r  r5   rZ   r9   r9   r:   0test_group_subplot_nonunique_cols_notimplemented	  s    zCTestDataFramePlots.test_group_subplot_nonunique_cols_notimplementedzsubplots, expected_msg)){   z(subplots should be a bool or an iterable)r   !each entry should be a list/tuple))r@   r  )r  r  c                 C   s\   t dt dd}t|}tjt|d |j|d W d    n1 sN0    Y  d S )Nr!   r  rT   r  r/   r   r   rV   rW   r   r5   )r7   r>   Zexpected_msgrX  r8   r9   r9   r:   test_group_subplot_bad_input	  s    z/TestDataFramePlots.test_group_subplot_bad_inputc                 C   s^   t dt dd}t|}tjtdd |jdgd W d    n1 sP0    Y  d S )Nr!   r  z Column label\(s\) \['bad_name'\]rT   )r   Zbad_namer  r  ry  r9   r9   r:   &test_group_subplot_invalid_column_name	  s    z9TestDataFramePlots.test_group_subplot_invalid_column_namec                 C   sh   t dt dt dd}t|}tjtdd  |jddgd W d    n1 sZ0    Y  d S )Nr!   r   zshould be in only one subplotrT   r  )r   r   r  r  ry  r9   r9   r:   $test_group_subplot_duplicated_column	  s    z7TestDataFramePlots.test_group_subplot_duplicated_column)r  r   r   c                 C   s`   t dt dd}t|}tjtdd  |jdg|d W d    n1 sR0    Y  d S )Nr!   r  z1When subplots is an iterable, kind must be one ofrT   r  r  )r7   r  rX  r8   r9   r9   r:   test_group_subplot_invalid_kind	  s    z2TestDataFramePlots.test_group_subplot_invalid_kindz index_name, old_label, new_label)Nr#  new)oldr  r  )Nr#  r#  )Nr#  r@   r#  )rY   r  r   c                 C   s   t ddgddggddgd}||j_|j|d}| |ks@J | dksPJ |j|||d	}| t|kstJ | t|ksJ d S )
Nr@   r   rg   Type AType Br   r  r#  )r  r]  xlabel)r   r-   r   r5   
get_xlabelr  str)r7   r  Z
index_nameZ	old_labelZ	new_labelr8   rc   r9   r9   r:   (test_xlabel_ylabel_dataframe_single_plot	  s    z;TestDataFramePlots.test_xlabel_ylabel_dataframe_single_plotzxlabel, ylabel))NN)X LabelN)NY Label)r  r  c                 C   st   d}d}t ddgddgg||gd}|j|||||d}| |d u rJ|n|ksTJ | |d u rf|n|kspJ d S )Nr	  r
  r@   r   rg   r   )r  rR   rS   r  r]  )r   r5   r  r  )r7   r  r  r]  ZxcolZycolr8   rc   r9   r9   r:   'test_xlabel_ylabel_dataframe_plane_plot	  s    z:TestDataFramePlots.test_xlabel_ylabel_dataframe_plane_plot)FTc                 C   sj   t dgj|dddgd}|jjD ]B}|j r"| dks@J | dksPJ | d dks"J q"d S )Nr   rU  )r   ri   r   )r.  r]  rj   rf   )	r   r5   rM  rF   r   Zget_visibler  r5  Z
get_yticks)r7   r.  Zax_dfrc   r9   r9   r:   test_secondary_y	  s    


z#TestDataFramePlots.test_secondary_yc                 C   sr   t tjddttdtdtddddd	}t	
d
" | }|j }W d    n1 sd0    Y  d S )Nr   r    r#   r$   r&   r!   r'   r(   r+   F)r   r/   r0   r1   r2   r   r3   r4   r   r   r   r5   r  )r7   r8   r   r9   r9   r:   test_plot_no_warning	
  s    z'TestDataFramePlots.test_plot_no_warning)NNNN)__name__
__module____qualname__rV   markZslowr;   rG   rJ   rN   Zxfailr\   rd   Zparametrizero   rx   rz   r~   r   r   r   r3   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/   r   r   r   r   r   r  r  r  r  r  r  r  r  r|   r   r'  r,  r-  r0  r3  r6  r:  r@  rA  rI  rJ  rX  r]  r^  rg  ri  r   r   ZCategoricalIndexrk  rn  rr  rs  rw  r~  paramtdZ
skip_if_nor  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  filterwarningsr  r  r  r  r  r  r  r  r  r  r  r  r  r  ro  r  r  r  r   r  r  r"  r&  r-  r0  r   r  Z_common_kindsr4  r5  r9  r;  r<  rA  rB  rC  rI  rJ  rL  rN  ZstdrP  rQ  rZ  r\  r^  ra  rh  rr  rs  rv  rw  rz  r|  r	   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  Z
_all_kindsr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r9   r9   r9   r:   r   6   sR  





	


	


	




	




	

	



	





	
	


				








			.   """***l
		
"	,
	



(((6	!(($S5
	
	

	
r   c                  C   sb   dd l m}  tjdd}| |d }| |d }| |d }| |d }|||||gfS )Nr   r   r  )r@   r   rz  r   )r  r   r   r  r  Zsubplot)r!  r  Zax_tlZax_llZax_trZax_lrr9   r9   r:   r  
  s    r  )4__doc__r   r   r  r  ro  r`   r  numpyr/   rV   Zpandas.util._test_decoratorsutilZ_test_decoratorsr  Zpandas.core.dtypes.apir   Zpandasr   r   r   r   r   r	   r
   r   r   r   Zpandas._testingZ_testingr   Zpandas.tests.plotting.commonr   r   r   r   r   r   r   r   r   r   r   r   r   Zpandas.io.formats.printingr   r  r   r!  r   r  r9   r9   r9   r:   <module>   sL   ,<

                   t