
    !g ;                         d dl Zd dlZd dlZd dlmZ dZ	 d dlm	Z
 d Zej                  j                  d        Zy# e$ r Y 'w xY w)    N)dot_plotFc                 \    t         r| j                  |       t        j                  |       y )N)
pdf_outputsavefigpltclose)pdffigs     d/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/graphics/tests/test_dotplot.pyclose_or_saver      s    CIIcN    c                 2   t         rddlm}  |d      }nd }t        j                          t        d      }t        j                         }t        ||      }|j                  d       t        ||       t        j                          t        d      }t        j                         }t        ||d      }|j                  d	       t        ||       t        j                  d
       t        j                         }t        j                  d      }t        ||      }|j                  d       |j                  d       t        ||       t        j                  d       t        j                         }t        j                  d      }t        ||d      }|j                  d       |j                  d       t        ||       t        j                  d
       t        j                         }t        j                  d      }t        ||d      }|j                  d       |j                  dd       t        ||       t        j                  d       t        j                         }t        j                  d      }t        ||dd      }|j                  d       |j!                  dd       t        ||       t        j                          t        j                         }t        j                  d      }t        ||      }|j                  d       t        ||       t        j                          t        j                         }t        j                  d      }t        ||d      }|j                  d       t        ||       t        j                          t        j                         }t        j                  d      }t        ||      }|j                  dd       |j                  d       t        ||       t        j                          t        j                         }t        d      D cg c]%  }dt        j"                  j%                  dd         ' }	}t        j"                  j'                  d       }t        ||	|!      }|j                  d"       t        ||       t        j                          t        j                         }t        j"                  j'                  d       }t        d      D cg c]7  }dt        j"                  j%                  dd         d#z   t)        |d$z         z   9 }	}t        ||	|d#%      }|j                  d&       t        ||       t        j                          t        j                  g d'      }t        j"                  j'                  d       }t        d      D cg c]7  }dt        j"                  j%                  dd         d#z   t)        |d$z         z   9 }	}t        ||	|d#d(      }|j                  d)      }
|
j+                  d*       t        ||       t        j                          t        j                  g d+      }t        j"                  j'                  d       }t        j,                  t        d,      t        j.                  d            j1                  t        j2                        }	t        j,                  t        j.                  d,      t        d            j1                  t        j2                        }t        d      D ci c]  }|d-|   d.|   d/d0d1 }}t        ||	|||2      }|j                  d3       t        ||       t        j                          t        j                         }t        d      }t        |t        j.                  d      |4      }|j                  d5       t        ||       t        j                          t        j                         }t5        j6                  t        d            }t5        j6                  t        j.                  d            }t        |||4      }|j                  d6       t        ||       t        j                          t        j                         }t        j                  d      }t        d      D cg c]  }d7 }}t        |||4      }|j                  d8       t        ||       t        j                          t        j                         }t        j                  d      }t        d      D cg c]  }d7 }}t        |||d9      }|j                  d:       t        ||       t        j                          t        j                         }t        j                  d      }t        d      D cg c]  }d7 }}dd;d<d=i}t        ||||>      }|j                  d?       t        ||       t        j                          t        j                  g d@      }d,t        j"                  j'                  d       z  }t        j,                  t        d      dA      }	t        d      D cg c]  }d7 }}t        j,                  t        j.                  d      dB      j1                  t        j2                        }|D cg c]	  }dCdDg|    }}t        |||	||dE      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dI       t        ||       t        j                          t        j                  g d@      }t        |||	||ddDdCgJ      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dK       t        ||       t        j                          t        j                  g d@      }d,t        j"                  j'                  d       z  }t        j,                  t        d      dA      }	t        d      D cg c]  }d7 }}t        j,                  t        j.                  d      dB      j1                  t        j2                        }|D cg c]	  }dCdDg|    }}t        |||	||ddL      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dM       t        ||       t        j                          t        j                  g d@      }dDdCg}t        |||	||dd|N      }|j9                         \  }}t?        tA        ||            }|D cg c]  }||   	 }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dO       t        ||       t        j                          t        j                  g d@      }d,t        j"                  j'                  d       z  }t        j,                  t        d      dA      }	t        d      D cg c]  }d7 }}t        j,                  t        j.                  d      dB      j1                  t        j2                        }|D cg c]	  }dCdDg|    }}t        |||	||dddP      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       t        jB                  dQd       |j                  dM       t        ||       t        j                          t        j                  g d@      }d,t        j"                  j'                  d       z  }t        j,                  t        d      dA      }	t        d      D cg c]  }d7 }}t        j,                  t        j.                  d      dB      j1                  t        j2                        }|D cg c]	  }dCdDg|    }}dRdSidRdTidU}dRdSidRdTidU}t        |||	||d||V      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dW       t        ||       t        j                          t        j                  g d@      }d,t        j"                  j'                  d       z  }t        j,                  t        d      dA      }	t        d      D cg c]  }d7 }}t        j,                  t        j.                  d      dB      j1                  t        j2                        }|D cg c]	  }dCdDg|    }}dRdSidRdTidU}dRdSidRdTidU}t        |||	||d||dX	      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dW       t        ||       t        j                          t        j                         }t        d      }t        j,                  t        dY      dA      j1                  t        j2                        }	t        j,                  t        j.                  dY      dB      j1                  t        j2                        }t        j,                  dZt        j.                  d[            j1                  t        j2                        }|D cg c]	  }g d\|    }}t        ||	|||]      }|j                  d^       t        ||       t        j                          t        j                  g d_      }t        d      }t        j,                  t        dY      dA      j1                  t        j2                        }	t        j,                  t        j.                  dY      dB      j1                  t        j2                        }t        j,                  dZt        j.                  d[            j1                  t        j2                        }|D cg c]	  }g d\|    }}t        ||	|||d`      }|j                  da      }
|
j+                  db       t        ||       t        j                          t        j                         }t        d      }t        j,                  t        dY      dA      j1                  t        j2                        }	t        j,                  t        j.                  dY      dB      j1                  t        j2                        }t        j,                  dZt        j.                  d[            j1                  t        j2                        }|D cg c]	  }g d\|    }}t        ||	|||g dcd      }|j                  de       t        ||       t        j                          t        j                         }t        j                  d      }g df}	g dg}t        ||	||h      }|j                  di       t        ||       t        j                          t        d      }t        d      D cg c]  }dj|dk|z   fz   }	}dl }dm }t        j                         }t        ||	|d#||n      }|j                  do       t        ||       t        j                          t        d      }t        d      D cg c]  }dj|dk|z   fz   }	}t        j                         }t        ||	|d#dpq      }|j                  dr       t        ||       t        j                          t        j                  g d@      }d,t        j"                  j'                  d       z  }g }	d}tE        |	      dk  rSt        t        j"                  j%                  d$d            D ]  }|	jG                  |        |d$z  }tE        |	      dk  rSt        j,                  t        j.                  d      dB      j1                  t        j2                        }|D cg c]	  }dCdDg|    }}t        ||	||ds      }|j9                         \  }}t        j:                  ||dFd$dGH      }|j=                  d       |j                  dt       t        ||       t         r|jI                          y y c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w )uNr   )PdfPagesztest_dotplot.pdf   )axzBasic horizontal dotplotF)r   
horizontalzBasic vertical dotplot)      )figsize(   zTall and skinny dotplotzx axis label)r   r   zShort and wide dotplotzy axis labelT)r   stripedzTall and skinny striped dotploti2   )r   r   r   zShort and wide striped dotplotr   z'Basic horizontal dotplot with few linesz%Basic vertical dotplot with few lines   z&Dotplot with adjusted horizontal rangeABCDEFGH   )size)linesr   z4Dotplot with user-supplied labels in the left marginz::   )r   r   split_namesz1Dotplot with user-supplied labels in both margins)皙?r    g)\(?皙?)r   r   r   r   z:Vertical dotplot with user-supplied labels in both margins)      ?g(\?)r    gQ?g(\?g333333?   rgbcosvp   g333333?)colormarkermsalpha)r   stylesr   marker_propsz&Dotplot with custom colors and symbols)	intervalsr   z Dotplot with symmetric intervalsz0Dotplot with symmetric intervals (Pandas inputs))r      z#Dotplot with nonsymmetric intervals)r-   r   r   z,Vertical dotplot with nonsymmetric intervals	lightgreyround)r'   solid_capstyle)r-   
line_propsr   z#Dotplot with custom line properties)r    r          ?r!   )r   r   )r   r   CatDog)r-   r   r+   r   stackedzcenter rightg-C6?)loc	numpointshandletextpadz Dotplot with two points per line)r-   r   r+   r   r6   styles_orderz0Dotplot with two points per line (reverse order))r-   r   r+   r   r6   r   z)Vertical dotplot with two points per line)r-   r   r+   r   r6   r   r:   z9Vertical dotplot with two points per line (reverse order))r-   r   r+   r   r6   r   r   ir'   orangepurple)r4   r5   )r-   r   r+   r   r6   r,   r2   z/Dotplot with color-matched points and intervals)r-   r   r+   r   r6   r,   r2   r      )r   r      
   )AxxByyCzz)r   r+   sectionsr   zDotplot with sections)r    r    g?r3   )r   r+   rC   r   r   zVertical dotplot with sections)r"   gHzG?)rA   r@   rB   )r   r+   rC   r   section_orderz(Dotplot with sections in specified order)ABCD)rF   rG   rE   rH   )r   
line_orderr   zDotplot with reordered linesz%d::%dd   c                     d| z   S )Nlft_ xs    r   <lambda>ztest_all.<locals>.<lambda>x  s
    &1* r   c                     d| z   S )Nrgt_rM   rN   s    r   rP   ztest_all.<locals>.<lambda>y  s
    6A: r   )r   r   r   fmt_left_namefmt_right_namez'Horizontal dotplot with name formattingright)r   r   r   
show_nameszShow right names only)r   r+   r   r6   z1Dotplot with different numbers of points per line)%r   matplotlib.backends.backend_pdfr   r   clfrangeaxesr   	set_titler   figurenparange
set_xlabel
set_ylabelset_xlimset_ylimrandomrandintnormalstrset_positionkrononesastypeint32pdSeriesget_legend_handles_labels	figlegend
draw_framedictzipylimlenappendr   )close_figuresreset_randomstater   r	   pointsr   r
   valskr   txtr+   r,   r-   irO   r2   handleslabelslegr:   lhlrC   rI   fmt_left	fmt_rightiis                               r   test_allr      s    <)* GGI2YF	B
6b
!CLL+,#s GGI2YF	B
6bU
3CLL)*#s JJv	B99R=D
6b
!CLL*+MM.!#s JJv	B99R=D
6bU
3CLL)*MM.!#s JJv	BYYr]F
6b$
/CLL23KKR#s JJv	BYYr]F
6b$5
ACLL12KKR#s JJL	BYYq\F
6b
!CLL:;#s JJL	BYYq\F
6bU
3CLL89#s JJL	BYYr]F
6b
!CKKRLL9:#s GGI	B:?)DQZ		))!Q/0DEDYY2&F
62
.CLLGH#s GGI	BYY2&FBi! 		))!Q/047#ac(B !E !
624
@CLLDE#s GGI	'	(BYY2&FBi! 		))!Q/047#ac(B !E !
624C
,,S
TC[!#s GGI	)	*BYY2&FGGE!Hbggaj)00:EWWRWWQZq*11"((;F8=aB34 fQi#/ / BL B
6v"%'CLL9:#s GGI	B2YF
6RWWR[R
8CLL34#s GGI	BYYuRy!F		"''"+&I
6Y2
6CLLCD#s GGI	BYYr]F!&r+A+I+
6Y2
6CLL67#s GGI	BYYr]F!&r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, , , +08 +0& , +0  +0( +0, < < <& 7 7$ 1s   >*Ad 
<Ad<Ad
>Ad	Ad	Ad	Ad	Ad#$Ad(4	Ad-	Ad24Ad7	Ad<Ae'	Ae@<AeE	AeFAeL+AeQ*AeV8Ae$ZAe)\Ae.a-Ae3)numpyr]   pandasrl   pyteststatsmodels.graphics.dotplotsr   r   matplotlib.pyplotpyplotr   ImportErrorr   mark
matplotlibr   rM   r   r   <module>r      sY       2 
	#
 I I  		s   < AA