
    M/Ph ;                         d dl Zd dlZd dlZd dlmZ dZ	 d dlm	Z
 n# e$ r Y nw xY wd Zej        j        d             ZdS )    N)dot_plotFc                 f    t           r|                     |           t          j        |           d S )N)
pdf_outputsavefigpltclose)pdffigs     g/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/graphics/tests/test_dotplot.pyclose_or_saver      s-     CIcNNNNN    c                 3   t           rddlm}  |d          }nd }t          j                     t          d          }t          j                    }t          ||          }|                    d           t          ||           t          j                     t          d          }t          j                    }t          ||d          }|                    d	           t          ||           t          j
        d
           t          j                    }t          j        d          }t          ||          }|                    d           |                    d           t          ||           t          j
        d           t          j                    }t          j        d          }t          ||d          }|                    d           |                    d           t          ||           t          j
        d
           t          j                    }t          j        d          }t          ||d          }|                    d           |                    dd           t          ||           t          j
        d           t          j                    }t          j        d          }t          ||dd          }|                    d           |                    dd           t          ||           t          j
                     t          j                    }t          j        d          }t          ||          }|                    d           t          ||           t          j
                     t          j                    }t          j        d          }t          ||d          }|                    d           t          ||           t          j
                     t          j                    }t          j        d          }t          ||          }|                    dd           |                    d           t          ||           t          j                     t          j                    }d t          d          D             }t          j                            d          }t          |||           }|                    d!           t          ||           t          j                     t          j                    }t          j                            d          }d" t          d          D             }t          |||d#$          }|                    d%           t          ||           t          j                     t          j        g d&          }t          j                            d          }d' t          d          D             }t          |||d#d(          }|                    d)          }	|	                    d*           t          ||           t          j                     t          j        g d+          }t          j                            d          }t          j        t          d,          t          j        d                                        t          j                  }t          j        t          j        d,          t          d                                        t          j                  }
d- t          d          D             }t          |||
||.          }|                    d/           t          ||           t          j                     t          j                    }t          d          }t          |t          j        d          |0          }|                    d1           t          ||           t          j                     t          j                    }t1          j        t          d                    }t1          j        t          j        d                    }t          |||0          }|                    d2           t          ||           t          j                     t          j                    }t          j        d          }d3 t          d          D             }t          |||0          }|                    d4           t          ||           t          j                     t          j                    }t          j        d          }d5 t          d          D             }t          |||d6          }|                    d7           t          ||           t          j                     t          j                    }t          j        d          }d8 t          d          D             }dd9d:d;i}t          ||||<          }|                    d=           t          ||           t          j                     t          j        g d>          }d,t          j                            d          z  }t          j        t          d          d?          }d@ t          d          D             }t          j        t          j        d          dA                              t          j                  }
dB |
D             }
t          ||||
|dC          }|                                \  }}t          j        ||dDdEdFG          }|                    d           |                    dH           t          ||           t          j                     t          j        g d>          }t          ||||
|ddIdJgK          }|                                \  }}t          j        ||dDdEdFG          }|                    d           |                    dL           t          ||           t          j                     t          j        g d>          }d,t          j                            d          z  }t          j        t          d          d?          }dM t          d          D             }t          j        t          j        d          dA                              t          j                  }
dN |
D             }
t          ||||
|ddO          }|                                \  }}t          j        ||dDdEdFG          }|                    d           |                    dP           t          ||           t          j                     t          j        g d>          }dIdJg}t          ||||
|dd|Q          }|                                \  }}t;          t=          ||                    fdR|D             }t          j        ||dDdEdFG          }|                    d           |                    dS           t          ||           t          j                     t          j        g d>          }d,t          j                            d          z  }t          j        t          d          d?          }dT t          d          D             }t          j        t          j        d          dA                              t          j                  }
dU |
D             }
t          ||||
|dddV          }|                                \  }}t          j        ||dDdEdFG          }|                    d           t          j        dWd           |                    dP           t          ||           t          j                     t          j        g d>          }d,t          j                            d          z  }t          j        t          d          d?          }dX t          d          D             }t          j        t          j        d          dA                              t          j                  }
dY |
D             }
dZd[idZd\id]}dZd[idZd\id]}t          ||||
|d||^          }|                                \  }}t          j        ||dDdEdFG          }|                    d           |                    d_           t          ||           t          j                     t          j        g d>          }d,t          j                            d          z  }t          j        t          d          d?          }d` t          d          D             }t          j        t          j        d          dA                              t          j                  }
da |
D             }
dZd[idZd\id]}dZd[idZd\id]}t          ||||
|d||db	  	        }|                                \  }}t          j        ||dDdEdFG          }|                    d           |                    d_           t          ||           t          j                     t          j                    }t          d          }t          j        t          dc          d?                              t          j                  }t          j        t          j        dc          dA                              t          j                  }
t          j        ddt          j        de                                        t          j                  }df |D             }t          |||
||g          }|                    dh           t          ||           t          j                     t          j        g di          }t          d          }t          j        t          dc          d?                              t          j                  }t          j        t          j        dc          dA                              t          j                  }
t          j        ddt          j        de                                        t          j                  }dj |D             }t          |||
||dk          }|                    dl          }	|	                    dm           t          ||           t          j                     t          j                    }t          d          }t          j        t          dc          d?                              t          j                  }t          j        t          j        dc          dA                              t          j                  }
t          j        ddt          j        de                                        t          j                  }dn |D             }t          |||
||g dop          }|                    dq           t          ||           t          j
                     t          j                    }t          j        d          }g dr}g ds}t          ||||t          }|                    du           t          ||           t          j                     t          d          }dv t          d          D             }dw }dx }t          j                    }t          |||d#||y          }|                    dz           t          ||           t          j                     t          d          }d{ t          d          D             }t          j                    }t          |||d#d|}          }|                    d~           t          ||           t          j                     t          j        g d>          }d,t          j                            d          z  }g }d}tA          |          dk     r]t          t          j        !                    dEd                    D ]}|"                    |           |dEz  }tA          |          dk     ]t          j        t          j        d          dA                              t          j                  }
d |
D             }
t          |||
|d          }|                                \  }}t          j        ||dDdEdFG          }|                    d           |                    d           t          ||           t           r|#                                 d S d S )Nr   )PdfPagesztest_dotplot.pdf   )axzBasic horizontal dotplotF)r   
horizontalzBasic vertical dotplot)      )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 dotploti2   )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                 Z    g | ](}d t           j                            dd                   )S )ABCDEFGHr      )nprandomrandint.0ks     r   
<listcomp>ztest_all.<locals>.<listcomp>o   s/    DDDQZ	))!Q//0DDDr   )size)linesr   z4Dotplot with user-supplied labels in the left marginc                     g | ]>}d t           j                            dd                   dz   t          |dz             z   ?S r   r   r   ::   r   r   r   strr    s     r   r#   ztest_all.<locals>.<listcomp>y   S     ! ! ! 	))!Q//047#ac((B ! ! !r   r(   )r%   r   split_namesz1Dotplot with user-supplied labels in both margins)皙?r.   g)\(?皙?c                     g | ]>}d t           j                            dd                   dz   t          |dz             z   ?S r'   r*   r    s     r   r#   ztest_all.<locals>.<listcomp>   r,   r   )r%   r   r-   r   z:Vertical dotplot with user-supplied labels in both margins)      ?g(\?)r.   gQ?g(\?g333333?   c                 6    i | ]}|d |         d|         dddS )rgbcosvp   g333333?)colormarkermsalpha r    s     r   
<dictcomp>ztest_all.<locals>.<dictcomp>   sI     B B B34 fQi#/ / B B Br   )r%   stylesr   marker_propsz&Dotplot with custom colors and symbols)	intervalsr   z Dotplot with symmetric intervalsz0Dotplot with symmetric intervals (Pandas inputs)c                     g | ]}d S )r)      r;   r!   is     r   r#   ztest_all.<locals>.<listcomp>       +++A+++r   z#Dotplot with nonsymmetric intervalsc                     g | ]}d S rA   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>   rE   r   )r?   r   r   z,Vertical dotplot with nonsymmetric intervalsc                     g | ]}d S rA   r;   )r!   xs     r   r#   ztest_all.<locals>.<listcomp>   rE   r   	lightgreyround)r7   solid_capstyle)r?   
line_propsr   z#Dotplot with custom line properties)r.   r.         ?r/   )r)   r)   c                     g | ]}d S rA   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>       ***1***r   )r   r)   c                 "    g | ]}d dg|         S CatDogr;   rC   s     r   r#   ztest_all.<locals>.<listcomp>   !    000AuenQ000r   )r?   r%   r=   r   stackedzcenter rightr)   g-C6?)loc	numpointshandletextpadz Dotplot with two points per linerS   rR   )r?   r%   r=   r   rU   styles_orderz0Dotplot with two points per line (reverse order)c                     g | ]}d S rA   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>   rO   r   c                 "    g | ]}d dg|         S rQ   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>   rT   r   )r?   r%   r=   r   rU   r   z)Vertical dotplot with two points per line)r?   r%   r=   r   rU   r   rY   c                      g | ]
}|         S r;   r;   )r!   llhs     r   r#   ztest_all.<locals>.<listcomp>   s    +++r!u+++r   z9Vertical dotplot with two points per line (reverse order)c                     g | ]}d S rA   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>
  rO   r   c                 "    g | ]}d dg|         S rQ   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>  rT   r   )r?   r%   r=   r   rU   r   r   ic                     g | ]}d S rA   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>  rO   r   c                 "    g | ]}d dg|         S rQ   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>  rT   r   r7   orangepurplerQ   )r?   r%   r=   r   rU   r>   rL   z/Dotplot with color-matched points and intervalsc                     g | ]}d S rA   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>2  rO   r   c                 "    g | ]}d dg|         S rQ   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>4  rT   r   )r?   r%   r=   r   rU   r>   rL   r      )r   r)      
   c                 "    g | ]}g d |         S )AxxByyCzzr;   r    s     r   r#   ztest_all.<locals>.<listcomp>J  $    ;;;Q%%%a(;;;r   )r%   r=   sectionsr   zDotplot with sections)r.   r.   g?rM   c                 "    g | ]}g d |         S rk   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>V  ro   r   )r%   r=   rp   r   r   zVertical dotplot with sections)r1   gHzG?c                 "    g | ]}g d |         S rk   r;   r    s     r   r#   ztest_all.<locals>.<listcomp>d  ro   r   )rm   rl   rn   )r%   r=   rp   r   section_orderz(Dotplot with sections in specified order)ABCD)ru   rv   rt   rw   )r%   
line_orderr   zDotplot with reordered linesc                 "    g | ]}d |d|z   fz  S z%d::%dd   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>w  %    666qXCE
"666r   c                     d| z   S )Nlft_r;   rH   s    r   <lambda>ztest_all.<locals>.<lambda>x  s
    &1* r   c                     d| z   S )Nrgt_r;   r   s    r   r   ztest_all.<locals>.<lambda>y  s
    6A: r   )r%   r   r-   fmt_left_namefmt_right_namez'Horizontal dotplot with name formattingc                 "    g | ]}d |d|z   fz  S rz   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>  r|   r   right)r%   r   r-   
show_nameszShow right names onlyc                 "    g | ]}d dg|         S rQ   r;   rC   s     r   r#   ztest_all.<locals>.<listcomp>  rT   r   )r%   r=   r   rU   z1Dotplot with different numbers of points per line)$r   matplotlib.backends.backend_pdfr   r   clfrangeaxesr   	set_titler   figurer   arange
set_xlabel
set_ylabelset_xlimset_ylimr   normalset_positionkrononesastypeint32pdSeriesget_legend_handles_labels	figlegend
draw_framedictzipylimlenr   appendr   )close_figuresreset_randomstater   r	   pointsr   r
   valsr%   txtr=   r>   r?   rL   handleslabelslegrY   rp   rx   fmt_left	fmt_rightiir"   r^   s                           @r   test_allr      su     <<<<<<h)** GIII2YYF	B
6b
!
!
!CLL+,,,#s GIII2YYF	B
6bU
3
3
3CLL)***#s Jv	B9R==D
6b
!
!
!CLL*+++MM.!!!#s Jv	B9R==D
6bU
3
3
3CLL)***MM.!!!#s Jv	BYr]]F
6b$
/
/
/CLL2333KKR#s Jv	BYr]]F
6b$5
A
A
ACLL1222KKR#s JLLL	BYq\\F
6b
!
!
!CLL:;;;#s JLLL	BYq\\F
6bU
3
3
3CLL8999#s JLLL	BYr]]F
6b
!
!
!CKKRLL9:::#s GIII	BDD%))DDDEY2&&F
62
.
.
.CLLGHHH#s GIII	BY2&&F! !Bii! ! !E
624
@
@
@CLLDEEE#s GIII	'''	(	(BY2&&F! !Bii! ! !E
624  C
,,S
T
TC[!!!#s GIII	)))	*	*BY2&&FGE!HHbgajj))00::EWRWQZZq**11"(;;FB B8=aB B BL
6v"%' ' 'CLL9:::#s GIII	B2YYF
6RWR[[R
8
8
8CLL3444#s GIII	BYuRyy!!F	"'"++&&I
6Y2
6
6
6CLLCDDD#s GIII	BYr]]F++r+++I
6Y2
6
6
6CLL6777#s GIII	BYr]]F++r+++I
6Y2%
H
H
HCLL?@@@#s GIII	BYr]]F++r+++I{(/1 1 2J
6Y:"
M
M
MCLL6777#s GIII	'''	(	(BryR(((FGE"IIu%%E**b		***IWRWR[[%((//99F00000F
6YeF4! ! !C2244OGV
-^q&,. . .CNN5LL3444#s GIII	'''	(	(B
6YeB %u~/ / /C 2244OGV
-^q&,. . .CNN5LLCDDD#s GIII	'''	(	(BryR(((FGE"IIu%%E**b		***IWRWR[[%((//99F00000F
6YeF4E3 3 3C2244OGV
-^q&,. . .CNN5LL<===#s GIII	'''	(	(B5>L
6YeB"? ? ?C 2244OGV	c&'""	#	#B++++l+++G
->Q&,. . .CNN5LLLMMM#s GIII	'''	(	(BryR(((FGE"IIu%%E**b		***IWRWR[[%((//99F00000F
6YeF4%A A AC2244OGV
-^q&,. . .CNN5HS"LL<===#s GIII	'''	(	(BryR(((FGE"IIu%%E**b		***IWRWR[[%((//99F00000F#X.#X.0 0L!8,!8,. .J
6YeF4l!# # #C 2244OGV
-^q&,. . .CNN5LLBCCC#s GIII	'''	(	(BryR(((FGE"IIu%%E**b		***IWRWR[[%((//99F00000F#X.#X.0 0L!8,!8,. .J
6YeF4l!e5 5 5C 2244OGV
-^q&,. . .CNN5LLBCCC#s GIII	B2YYFGE"IIu%%,,RX66EWRWR[[%((//99Fww,,33BH==H;;(;;;H
6vR
P
P
PCLL()))#s GIII	$$$	%	%B2YYFGE"IIu%%,,RX66EWRWR[[%((//99Fww,,33BH==H;;(;;;H
6v#u> > >C
,,7
8
8C[!!!#s GIII	B2YYFGE"IIu%%,,RX66EWRWR[[%((//99Fww,,33BH==H;;(;;;H
6vR///1 1 1CLL;<<<#s JLLL	BYq\\F   E%%%J
6:"
E
E
ECLL/000#s GIII2YYF66E"II666E$$H%%I	B
624!))E E ECLL:;;;#s GIII2YYF66E"II666E	B
624%' ' 'CLL()))#s GIII	'''	(	(BryR(((FE	
B
e**r//ry((A..// 	 	ALL
a e**r// WRWR[[%((//99F00000F
6v4! ! !C2244OGV
-^q&,. . .CNN5LLDEEE#s 		 r   )numpyr   pandasr   pyteststatsmodels.graphics.dotplotsr   r   matplotlib.pyplotpyplotr   ImportErrorr   mark
matplotlibr   r;   r   r   <module>r      s             2 2 2 2 2 2 
	####### 	 	 	D	   I I I I Is    %%