U
    Ãmœd ;  ã                   @   sj   d dl Zd dlZd dlZd dlmZ dZzd dlm	Z
 W n ek
rL   Y nX dd„ Zejjdd„ ƒZdS )é    N)Údot_plotFc                 C   s   t r|  |¡ t |¡ d S )N)Ú
pdf_outputZsavefigÚpltÚclose)ÚpdfÚfig© r   ú`/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/graphics/tests/test_dotplot.pyÚclose_or_save   s    
r
   c                    sð  t rddlm} |dƒ}nd }t ¡  tdƒ}t ¡ }t||d�}| d¡ t	||ƒ t ¡  tdƒ}t ¡ }t||dd�}| d	¡ t	||ƒ tj
d
d� t ¡ }t d¡}t||d�}| d¡ | d¡ t	||ƒ tj
dd� t ¡ }t d¡}t||dd�}| d¡ | d¡ t	||ƒ tj
d
d� t ¡ }t d¡}t||dd�}| d¡ | dd¡ t	||ƒ tj
dd� t ¡ }t d¡}t||ddd�}| d¡ | dd¡ t	||ƒ t 
¡  t ¡ }t d¡}t||d�}| d¡ t	||ƒ t 
¡  t ¡ }t d¡}t||dd�}| d¡ t	||ƒ t 
¡  t ¡ }t d¡}t||d�}| dd¡ | d¡ t	||ƒ t ¡  t ¡ }dd„ tdƒD ƒ}tjjdd �}t|||d!�}| d"¡ t	||ƒ t ¡  t ¡ }tjjdd �}d#d„ tdƒD ƒ}t|||d$d%�}| d&¡ t	||ƒ t ¡  t d'd'd(d)g¡}tjjdd �}d*d„ tdƒD ƒ}t|||d$dd+�}| d,¡}	|	 d-¡ t	||ƒ t ¡  t d'd.d/d0g¡}tjjdd �}t td1ƒt d¡¡ tj¡}t t d1¡tdƒ¡ tj¡}
d2d3„ tdƒD ƒ}t|||
||d4�}| d5¡ t	||ƒ t ¡  t ¡ }tdƒ}t|t d¡|d6�}| d7¡ t	||ƒ t ¡  t ¡ }t tdƒ¡}t t d¡¡}t|||d6�}| d8¡ t	||ƒ t ¡  t ¡ }t d¡}d9d„ tdƒD ƒ}t|||d6�}| d:¡ t	||ƒ t ¡  t ¡ }t d¡}d;d„ tdƒD ƒ}t|||dd<�}| d=¡ t	||ƒ t ¡  t ¡ }t d¡}d>d„ tdƒD ƒ}dd?d@dAœi}t||||dB�}| dC¡ t	||ƒ t ¡  t d'd'dDd)g¡}d1tjjdd � }t tdƒdE¡}dFd„ tdƒD ƒ}t t d¡dG¡ tj¡}
dHd„ |
D ƒ}
t||||
|ddI�}| ¡ \}}tj||dJdKdLdM�}| d¡ | dN¡ t	||ƒ t ¡  t d'd'dDd)g¡}t||||
|ddOdPgdQ�}| ¡ \}}tj||dJdKdLdM�}| d¡ | dR¡ t	||ƒ t ¡  t d'd'dDd)g¡}d1tjjdd � }t tdƒdE¡}dSd„ tdƒD ƒ}t t d¡dG¡ tj¡}
dTd„ |
D ƒ}
t||||
|dddU�}| ¡ \}}tj||dJdKdLdM�}| d¡ | dV¡ t	||ƒ t ¡  t d'd'dDd)g¡}dOdPg}t||||
|dd|dW�}| ¡ \}}tt||ƒƒ‰ ‡ fdXd„|D ƒ}tj||dJdKdLdM�}| d¡ | dY¡ t	||ƒ t ¡  t d'd'dDd)g¡}d1tjjdd � }t tdƒdE¡}dZd„ tdƒD ƒ}t t d¡dG¡ tj¡}
d[d„ |
D ƒ}
t||||
|dddd\�}| ¡ \}}tj||dJdKdLdM�}| d¡ t d]d¡ | dV¡ t	||ƒ t ¡  t d'd'dDd)g¡}d1tjjdd � }t tdƒdE¡}d^d„ tdƒD ƒ}t t d¡dG¡ tj¡}
d_d„ |
D ƒ}
d`daid`dbidcœ}d`daid`dbidcœ}t||||
|d||dd�}| ¡ \}}tj||dJdKdLdM�}| d¡ | de¡ t	||ƒ t ¡  t d'd'dDd)g¡}d1tjjdd � }t tdƒdE¡}dfd„ tdƒD ƒ}t t d¡dG¡ tj¡}
dgd„ |
D ƒ}
d`daid`dbidcœ}d`daid`dbidcœ}t||||
|d||ddh�	}| ¡ \}}tj||dJdKdLdM�}| d¡ | de¡ t	||ƒ t ¡  t ¡ }tdƒ}t tdiƒdE¡ tj¡}t t di¡dG¡ tj¡}
t djt dk¡¡ tj¡}dld„ |D ƒ}t|||
||dm�}| dn¡ t	||ƒ t ¡  t d'd'dodDg¡}tdƒ}t tdiƒdE¡ tj¡}t t di¡dG¡ tj¡}
t djt dk¡¡ tj¡}dpd„ |D ƒ}t|||
||ddq�}| dr¡}	|	 ds¡ t	||ƒ t ¡  t ¡ }tdƒ}t tdiƒdE¡ tj¡}t t di¡dG¡ tj¡}
t djt dk¡¡ tj¡}dtd„ |D ƒ}t|||
||dudvdwgdx�}| dy¡ t	||ƒ t 
¡  t ¡ }t d¡}dzd{d|d}g}d{d|dzd}g}t||||d~�}| d¡ t	||ƒ t ¡  tdƒ}d€d„ tdƒD ƒ}d�d‚„ }dƒd‚„ }t ¡ }t|||d$||d„�}| d…¡ t	||ƒ t ¡  tdƒ}d†d„ tdƒD ƒ}t ¡ }t|||d$d‡dˆ�}| d‰¡ t	||ƒ t ¡  t d'd'dDd)g¡}d1tjjdd � }g }d}t |ƒdk �rfttj !dKd¡ƒD ]}| "|¡ �qH|dK7 }�q(t t d¡dG¡ tj¡}
dŠd„ |
D ƒ}
t|||
|dd‹�}| ¡ \}}tj||dJdKdLdM�}| d¡ | dŒ¡ t	||ƒ t �rì| #¡  d S )�Nr   )ÚPdfPagesztest_dotplot.pdfé   )ÚaxzBasic horizontal dotplotF)r   Ú
horizontalzBasic vertical dotplot)é   é   )Zfigsizeé(   zTall and skinny dotplotzx axis label)r   r   zShort and wide dotplotzy axis labelT)r   ÚstripedzTall and skinny striped dotplotiöÿÿÿé2   )r   r   r   zShort and wide striped dotplotr   z'Basic horizontal dotplot with few linesz%Basic vertical dotplot with few linesé   z&Dotplot with adjusted horizontal rangec                 S   s   g | ]}d t j dd¡ ‘qS )ÚABCDEFGHr   é   )ÚnpÚrandomÚrandint©Ú.0Úkr   r   r	   Ú
<listcomp>o   s     ztest_all.<locals>.<listcomp>)Úsize)Úlinesr   z4Dotplot with user-supplied labels in the left marginc                 S   s.   g | ]&}d t j dd¡ d t|d ƒ ‘qS ©r   r   r   ú::é   ©r   r   r   Ústrr   r   r   r	   r   y   s   ÿr!   )r   r   Úsplit_namesz1Dotplot with user-supplied labels in both marginsgš™™™™™¹?g)\�Âõ(ì?gš™™™™™é?c                 S   s.   g | ]&}d t j dd¡ d t|d ƒ ‘qS r    r#   r   r   r   r	   r   ƒ   s   ÿ)r   r   r%   r   z:Vertical dotplot with user-supplied labels in both margins)ç      à?gö(\�Âõð?gìQ¸…ë±?gö(\�Âõè?g333333ë?é   c                 S   s$   i | ]}|d | d| dddœ“qS )ZrgbcZosvpé   g333333ã?)ÚcolorÚmarkerÚmsÚalphar   r   r   r   r	   Ú
<dictcomp>‘   s   ÿ  ÿztest_all.<locals>.<dictcomp>)r   Ústylesr   Úmarker_propsz&Dotplot with custom colors and symbols)Ú	intervalsr   z Dotplot with symmetric intervalsz0Dotplot with symmetric intervals (Pandas inputs)c                 S   s   g | ]}d ‘qS ©)r"   é   r   ©r   Úir   r   r	   r   ­   s     z#Dotplot with nonsymmetric intervalsc                 S   s   g | ]}d ‘qS r1   r   r3   r   r   r	   r   ¶   s     )r0   r   r   z,Vertical dotplot with nonsymmetric intervalsc                 S   s   g | ]}d ‘qS r1   r   )r   Úxr   r   r	   r   ¿   s     Z	lightgreyÚround)r)   Zsolid_capstyle)r0   Ú
line_propsr   z#Dotplot with custom line propertiesg      è?)r"   r"   c                 S   s   g | ]}d ‘qS r1   r   r   r   r   r	   r   Ë   s     )r   r"   c                 S   s   g | ]}d dg| ‘qS ©ÚCatÚDogr   r3   r   r   r	   r   Í   s     )r0   r   r.   r   Ústackedzcenter rightr"   g-Cëâ6?)ÚlocZ	numpointsZhandletextpadz Dotplot with two points per liner:   r9   )r0   r   r.   r   r;   Ústyles_orderz0Dotplot with two points per line (reverse order)c                 S   s   g | ]}d ‘qS r1   r   r   r   r   r	   r   é   s     c                 S   s   g | ]}d dg| ‘qS r8   r   r3   r   r   r	   r   ë   s     )r0   r   r.   r   r;   r   z)Vertical dotplot with two points per line)r0   r   r.   r   r;   r   r=   c                    s   g | ]}ˆ | ‘qS r   r   )r   Úl©Zlhr   r	   r   þ   s     z9Vertical dotplot with two points per line (reverse order)c                 S   s   g | ]}d ‘qS r1   r   r   r   r   r	   r   
  s     c                 S   s   g | ]}d dg| ‘qS r8   r   r3   r   r   r	   r     s     )r0   r   r.   r   r;   r   r   iìÿÿÿc                 S   s   g | ]}d ‘qS r1   r   r   r   r   r	   r     s     c                 S   s   g | ]}d dg| ‘qS r8   r   r3   r   r   r	   r     s     r)   ZorangeÚpurpler8   )r0   r   r.   r   r;   r/   r7   z/Dotplot with color-matched points and intervalsc                 S   s   g | ]}d ‘qS r1   r   r   r   r   r	   r   2  s     c                 S   s   g | ]}d dg| ‘qS r8   r   r3   r   r   r	   r   4  s     )r0   r   r.   r   r;   r/   r7   r   é   )r   r"   é   é
   c                 S   s   g | ]}d ddg| ‘qS ©ÚAxxÚByyÚCzzr   r   r   r   r	   r   J  s     )r   r.   Úsectionsr   zDotplot with sectionsgÍÌÌÌÌÌì?c                 S   s   g | ]}d ddg| ‘qS rD   r   r   r   r   r	   r   V  s     )r   r.   rH   r   r   zVertical dotplot with sections)r&   gHáz®Gñ?c                 S   s   g | ]}d ddg| ‘qS rD   r   r   r   r   r	   r   d  s     rF   rE   rG   )r   r.   rH   r   Zsection_orderz(Dotplot with sections in specified orderÚAÚBÚCÚD)r   Ú
line_orderr   zDotplot with reordered linesc                 S   s   g | ]}d |d| f ‘qS ©z%d::%déd   r   r3   r   r   r	   r   w  s     c                 S   s   d|  S )NZlft_r   ©r5   r   r   r	   Ú<lambda>x  ó    ztest_all.<locals>.<lambda>c                 S   s   d|  S )NZrgt_r   rP   r   r   r	   rQ   y  rR   )r   r   r%   Zfmt_left_nameZfmt_right_namez'Horizontal dotplot with name formattingc                 S   s   g | ]}d |d| f ‘qS rN   r   r3   r   r   r	   r   ƒ  s     Úright)r   r   r%   Z
show_nameszShow right names onlyc                 S   s   g | ]}d dg| ‘qS r8   r   r3   r   r   r	   r   •  s     )r   r.   r   r;   z1Dotplot with different numbers of points per line)$r   Zmatplotlib.backends.backend_pdfr   r   ZclfÚrangeZaxesr   Ú	set_titler
   Zfigurer   ZarangeZ
set_xlabelZ
set_ylabelZset_xlimZset_ylimr   ÚnormalZset_positionZkronZonesZastypeZint32ÚpdZSeriesZget_legend_handles_labelsZ	figlegendZ
draw_frameÚdictÚzipZylimÚlenr   Úappendr   )Zclose_figuresZreset_randomstater   r   Zpointsr   r   Úvalsr   Útxtr.   r/   r0   r7   ZhandlesÚlabelsÚlegr=   rH   rM   Zfmt_leftZ	fmt_rightÚiir   r   r?   r	   Útest_all   sð   





























ÿ

ÿ
ÿ


ÿ
ÿ












ÿ


 ÿÿ


  þÿ



  ÿÿ


   þÿ



   ÿÿ


ÿÿ
  þÿ


ÿÿ
   þÿ




  ÿ


ÿ





 ÿ


ÿ

 ÿÿ


ra   )Únumpyr   ZpandasrW   ZpytestZstatsmodels.graphics.dotplotsr   r   Zmatplotlib.pyplotZpyplotr   ÚImportErrorr
   ÚmarkZ
matplotlibra   r   r   r   r	   Ú<module>   s   