ó
áp7]c           @   sƒ   d  d l  Z d  d l Z d  d l m Z d  d l Z e Z y d  d l	 j
 Z Wn e k
 r` n Xd „  Z e j j d „  ƒ Z d S(   iÿÿÿÿN(   t   dot_plotc         C   s   t  r |  j | ƒ n  d  S(   N(   t
   pdf_outputt   savefig(   t   pdft   fig(    (    sF   lib/python2.7/site-packages/statsmodels/graphics/tests/test_dotplot.pyt   close_or_save   s    c         C   sÔ  t  r% d d l m } | d ƒ } n d  } t j ƒ  t d ƒ } t j ƒ  } t | d | ƒ} | j	 d ƒ t
 | | ƒ t j ƒ  t d ƒ } t j ƒ  } t | d | d t ƒ} | j	 d ƒ t
 | | ƒ t j d	 dm ƒ t j ƒ  } t j d ƒ } t | d | ƒ} | j	 d ƒ | j d ƒ t
 | | ƒ t j d	 dn ƒ t j ƒ  } t j d ƒ } t | d | d t ƒ} | j	 d ƒ | j d ƒ t
 | | ƒ t j d	 do ƒ t j ƒ  } t j d ƒ } t | d | d t ƒ} | j	 d ƒ | j d d ƒ t
 | | ƒ t j d	 dp ƒ t j ƒ  } t j d ƒ } t | d | d t d t ƒ} | j	 d ƒ | j d d ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d
 ƒ } t | d | ƒ} | j	 d ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d
 ƒ } t | d | d t ƒ} | j	 d ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d ƒ } t | d | ƒ} | j d d ƒ | j	 d ƒ t
 | | ƒ t j ƒ  t j ƒ  } g  t d ƒ D] } d t j j d d ƒ ^ q§}	 t j j d d ƒ } t | d |	 d | ƒ} | j	 d ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j j d d ƒ } g  t d ƒ D]1 } d t j j d d ƒ d  t | d! ƒ ^ qK}	 t | d |	 d | d" d  ƒ} | j	 d# ƒ t
 | | ƒ t j ƒ  t j d$ d$ d% d& g ƒ } t j j d d ƒ } g  t d ƒ D]1 } d t j j d d ƒ d  t | d! ƒ ^ q}	 t | d |	 d | d" d  d t ƒ} | j	 d' ƒ }
 |
 j dq ƒ t
 | | ƒ t j ƒ  t j d$ d* d+ d, g ƒ } t j j d d ƒ } t j t d- ƒ t j d
 ƒ ƒ j t j ƒ }	 t j t j d- ƒ t d
 ƒ ƒ j t j ƒ } d. „  t d
 ƒ Dƒ } t | d |	 d/ | d | d0 | ƒ} | j	 d1 ƒ t
 | | ƒ t j ƒ  t j ƒ  } t d ƒ } t | d2 t j d ƒ d | ƒ} | j	 d3 ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j t d ƒ ƒ } t j t j d ƒ ƒ } t | d2 | d | ƒ} | j	 d4 ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d ƒ } g  t d ƒ D] } dr ^ qq} t | d2 | d | ƒ} | j	 d6 ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d ƒ } g  t d ƒ D] } ds ^ qç} t | d2 | d | d t ƒ} | j	 d7 ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d ƒ } g  t d ƒ D] } dt ^ qc} i i d8 d9 6d: d; 6d 6} t | d2 | d< | d | ƒ} | j	 d= ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d- t j j d d ƒ } t j t d ƒ du ƒ }	 g  t d ƒ D] } dv ^ q+	} t j t j d ƒ dw ƒ j t j ƒ } g  | D] } d? d@ g | ^ qk	} t | d2 | d |	 d/ | d | dA t ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dF ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } t | d2 | d |	 d/ | d | dA t dG d@ d? g ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dH ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d- t j j d d ƒ } t j t d ƒ dx ƒ }	 g  t d ƒ D] } dy ^ q#} t j t j d ƒ dz ƒ j t j ƒ } g  | D] } d? d@ g | ^ qc} t | d2 | d |	 d/ | d | dA t d t ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dI ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d@ d? g } t | d2 | d |	 d/ | d | dA t d t dG | ƒ} | j ƒ  \ } } t" t# | | ƒ ƒ } g  | D] } | | ^ qž} t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dJ ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d- t j j d d ƒ } t j t d ƒ d{ ƒ }	 g  t d ƒ D] } d| ^ q_} t j t j d ƒ d} ƒ j t j ƒ } g  | D] } d? d@ g | ^ qŸ} t | d2 | d |	 d/ | d | dA t d t d t ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ t j$ dK d ƒ | j	 dI ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d- t j j d d ƒ } t j t d ƒ d~ ƒ }	 g  t d ƒ D] } d ^ q¾} t j t j d ƒ d€ ƒ j t j ƒ } g  | D] } d? d@ g | ^ qþ} i i dL d9 6d? 6i dM d9 6d@ 6} i i dL d9 6d? 6i dM d9 6d@ 6} t | d2 | d |	 d/ | d | dA t d0 | d< | ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dN ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d- t j j d d ƒ } t j t d ƒ d ƒ }	 g  t d ƒ D] } d‚ ^ qQ} t j t j d ƒ dƒ ƒ j t j ƒ } g  | D] } d? d@ g | ^ q‘} i i dL d9 6d? 6i dM d9 6d@ 6} i i dL d9 6d? 6i dM d9 6d@ 6} t | d2 | d |	 d/ | d | dA t d0 | d< | d t ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dN ƒ t
 | | ƒ t j ƒ  t j ƒ  } t d ƒ } t j t dO ƒ d„ ƒ j t j ƒ }	 t j t j dO ƒ d… ƒ j t j ƒ } t j d† t j dQ ƒ ƒ j t j ƒ } g  | D] } dR dS dT g | ^ q"} t | d |	 d/ | dU | d | ƒ} | j	 dV ƒ t
 | | ƒ t j ƒ  t j d$ d$ dW d> g ƒ } t d ƒ } t j t dO ƒ d‡ ƒ j t j ƒ }	 t j t j dO ƒ dˆ ƒ j t j ƒ } t j d‰ t j dQ ƒ ƒ j t j ƒ } g  | D] } dR dS dT g | ^ q)} t | d |	 d/ | dU | d | d t ƒ} | j	 dX ƒ }
 |
 j dŠ ƒ t
 | | ƒ t j ƒ  t j ƒ  } t d ƒ } t j t dO ƒ d‹ ƒ j t j ƒ }	 t j t j dO ƒ dŒ ƒ j t j ƒ } t j d t j dQ ƒ ƒ j t j ƒ } g  | D] } dR dS dT g | ^ q6} t | d |	 d/ | dU | d | dZ dS dR dT g ƒ} | j	 d[ ƒ t
 | | ƒ t j ƒ  t j ƒ  } t j d
 ƒ } d\ d] d^ d_ g }	 d] d^ d\ d_ g } t | d |	 d` | d | ƒ} | j	 da ƒ t
 | | ƒ t j ƒ  t d ƒ } g  t d ƒ D] } db | dc | f ^ qF}	 dd „  } de „  } t j ƒ  } t | d |	 d | d" d  df | dg | ƒ} | j	 dh ƒ t
 | | ƒ t j ƒ  t d ƒ } g  t d ƒ D] } db | dc | f ^ që}	 t j ƒ  } t | d |	 d | d" d  di dj ƒ} | j	 dk ƒ t
 | | ƒ t j ƒ  t j d$ d$ d> d& g ƒ } d- t j j d d ƒ } g  }	 d } xS t% |	 ƒ d k  rôx0 t t j j d! d
 ƒ ƒ D] } |	 j& | ƒ qÐW| d! 7} q¢Wt j t j d ƒ dŽ ƒ j t j ƒ } g  | D] } d? d@ g | ^ q#} t | d |	 d/ | d | dA t ƒ} | j ƒ  \ } } t j  | | dB dC d! dD dE ƒ} | j! t ƒ | j	 dl ƒ t
 | | ƒ t  rÐ| j' ƒ  n  d  S(   Niÿÿÿÿ(   t   PdfPagess   test_dotplot.pdfi   t   axs   Basic horizontal dotplott
   horizontals   Basic vertical dotplott   figsizei   i   i(   s   Tall and skinny dotplots   x axis labels   Short and wide dotplots   y axis labelt   stripeds   Tall and skinny striped dotplotiöÿÿÿi2   s   Short and wide striped dotplots'   Basic horizontal dotplot with few liness%   Basic vertical dotplot with few linesi   s&   Dotplot with adjusted horizontal ranget   ABCDEFGHi    i   t   sizet   liness4   Dotplot with user-supplied labels in the left margins   ::i   t   split_namess1   Dotplot with user-supplied labels in both marginsgš™™™™™¹?g)\Âõ(ì?gš™™™™™é?s:   Vertical dotplot with user-supplied labels in both marginsg      à?gö(\Âõð?gìQ¸…ë±?gö(\Âõè?g333333ë?i   c         S   s=   i  |  ]3 } i d  | d 6d | d 6d d 6d d 6| “ q S(   t   rgbct   colort   osvpt   markeri   t   msg333333ã?t   alpha(    (   t   .0t   k(    (    sF   lib/python2.7/site-packages/statsmodels/graphics/tests/test_dotplot.pys
   <dictcomp>   s   	t   stylest   marker_propss&   Dotplot with custom colors and symbolst	   intervalss    Dotplot with symmetric intervalss0   Dotplot with symmetric intervals (Pandas inputs)i   s#   Dotplot with nonsymmetric intervalss,   Vertical dotplot with nonsymmetric intervalst	   lightgreyR   t   roundt   solid_capstylet
   line_propss#   Dotplot with custom line propertiesg      è?t   Catt   Dogt   stackeds   center rightt	   numpointst   handletextpadg-Cëâ6?s    Dotplot with two points per linet   styles_orders0   Dotplot with two points per line (reverse order)s)   Vertical dotplot with two points per lines9   Vertical dotplot with two points per line (reverse order)iìÿÿÿt   oranget   purples/   Dotplot with color-matched points and intervalsi   i   i
   t   Axxt   Byyt   Czzt   sectionss   Dotplot with sectionsgÍÌÌÌÌÌì?s   Vertical dotplot with sectionsgHáz®Gñ?t   section_orders(   Dotplot with sections in specified ordert   At   Bt   Ct   Dt
   line_orders   Dotplot with reordered liness   %d::%did   c         S   s   d |  S(   Nt   lft_(    (   t   x(    (    sF   lib/python2.7/site-packages/statsmodels/graphics/tests/test_dotplot.pyt   <lambda>w  t    c         S   s   d |  S(   Nt   rgt_(    (   R1   (    (    sF   lib/python2.7/site-packages/statsmodels/graphics/tests/test_dotplot.pyR2   x  R3   t   fmt_left_namet   fmt_right_names'   Horizontal dotplot with name formattingt
   show_namest   rights   Show right names onlys1   Dotplot with different numbers of points per line(   i   i   (   i   i   (   i   i   (   i   i   (   g      à?gö(\Âõð?(   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i    i   (   i   i   (   i   i   (   i    i   (   i   i   (   i   i   (   i    i   (   i   i   (   i   i   (   i    i   (   i   i   (   i   i   (   i    i   (   i   i   (   i    i   (   i    i   i   (   i   i   (   i    i   (   i    i   i   (   g      à?gHáz®Gñ?(   i   i   (   i    i   (   i    i   i   (   i    i   ((   R   t   matplotlib.backends.backend_pdfR   t   Nonet   pltt   clft   ranget   axesR    t	   set_titleR   t   Falset   figuret   npt   aranget
   set_xlabelt
   set_ylabelt   Truet   set_xlimt   set_ylimt   randomt   randintt   normalt   strt   set_positiont   kront   onest   astypet   int32t   pdt   Seriest   get_legend_handles_labelst	   figlegendt
   draw_framet   dictt   zipt   ylimt   lent   appendt   close(   t   close_figurest   reset_randomstateR   R   t   pointsR   R   t   valsR   R   t   txtR   R   R   t   iR1   R   t   handlest   labelst   legR#   t   lht   lR)   R/   t   fmt_leftt	   fmt_rightt   ii(    (    sF   lib/python2.7/site-packages/statsmodels/graphics/tests/test_dotplot.pyt   test_all   sŒ   





2
A
A	
--	
!




'#	
	
'#	
	
'#	
'#		
'#	
$''&$
$''&
$''&!

-		
-	
"'#	(   t   numpyRB   t   pytestt   statsmodels.graphics.dotplotsR    t   pandasRR   R@   R   t   matplotlib.pyplott   pyplotR;   t   ImportErrorR   t   markt
   matplotlibRk   (    (    (    sF   lib/python2.7/site-packages/statsmodels/graphics/tests/test_dotplot.pyt   <module>   s   	