
p7]c           @   so   d  d l  Z d  d l m Z d d l m Z d d d d d d d d d e d e e d d d d d d  Z	 d S(   iN(   t   rangei   (   t   utilst   bothc   E         s  d d l  j } t j |  \ } } t j |   }  d   } | |  } | |  } | |  } | |  } t |   } | d k r t j |  } n  | d k r t j	 |  } n  | d k r t j	 |  } n  d } t t
 |   } | d k	 rt t
 |   } n  | t k r&t } d } n? | t k rAt } | } n$ | d k } | d k r_| n d } | | } | j d  | j d  | d k rt t
 |   } | j   n | } |	 d k rt t
 |   } | j   n |	 } i  } x t |  D] } | d k	 r&| | | k r&qn  |	 d k	 rH| | |	 k rHqn  | | | | f }  |  | k rug  | |  <n  | |  j |  qW| j   j | j j    }! |! j |! j }" }# t |  }$ d@ \ }% }& | r| j | j | j  }' n | j | j | j  }' | |# }( | r;|& |% | |( t |$  }) n |& |% t |$  }) | d k	 rd|   n t t
 |       j   | r  d d d    n  t    }* |* d k r|) d t |*  d }+ n d	 }+   f d
     D }, d d d d d d d g }- | d k r%d     D } n  x t |*  D] }.   |. }/ d | |/ k rq|- |. t |-  | |/ d <n  d | |/ k rd | |/ d <n  d | |/ k r2|+ d k rd n d | |/ d <q2q2W| d k rd     D } n  xr t |*  D]d }.   |. }/ d | |/ k r&d | |/ d <n  d | |/ k r|+ d k rHd n d | |/ d <qqW| r| d k r}|& |) d n |& }0 n |% |) d }0 t
   }1 g  }2 xq| D]i}3 | rA| rp|3 | d k r|0 |) d n |0 }4 | j dA |4 |4 f |0 d |( |0 d |( f d d d  | j d! d | j d |0 d" |( |3 d# d$ d% d$ d  | j }5 |5 j d&  |0 |( 8}0 qAt g  | D] }6 |6 d |3 k rz|6 ^ qz }7 | j |0 |) d d' |0 |7 d |) |) d d' f dB dC d d d  | j d! d d* t | j |0 |7 d |) d d+ |3 d# d$ d% d, d  | j }5 |5 j d&  n  d }8 x| D]}9 |3 |9 f | k rlqNn  | r| j  |0 d d n | j! |0 d d | d k	 r|9 j" |  }: t |:  d k r|: d |: d }; }< q|9 d }; }< n |9 d }; }< | d k	 r| |;  }; n  | d k	 r3| |<  }< n  | r|8 d d k r| r| j dD |0 |) d |0 |) d f |0 |) d |0 |) d f d d- d  | j d! d q| j |0 |) d |0 |) d f dE dF d d- d  | j d! d n  |8 d 7}8 | j#   dG k rs	| r>	| j d0 |" |0 |; d# d1 d% d$ d  | j d2 d3 qs	| j |0 d0 |# |; d# d$ d% d4 d  | j d2 d3 n  | j#   dH k r
|< d k	 r
| r	| j d d5 |" |0 |< d# d. d% d$ d  | j d2 d3 q	
| j |0 d d5 |# |< d# d$ d% d, d  | j d2 d3 q
n  |2 j |0  xt$ | |3 |9 f  D]\ }= }> d }? |
 rf
|) d6 |, | |> |+ }? n  |  |> }@ | d k	 rPt j% | |>  r
|@ | |> |@ | |> }A }B n% |@ | |> d |@ | |> d }A }B | r| j& |A |B g |0 |? |0 |? g d7 d  |' | | |> qP| j& |0 |? |0 |? g |A |B g d7 d  |' | | |> n  | |> }C |C |1 k rl|C n d }D |1 j' |C  | r| j& |@ g |0 |? g d8 d9 d  |' d: |D | |C q0
| j& |0 |? g |@ g d8 d9 d  |' d: |D | |C q0
W| r|0 |) 8}0 qN|0 |) 7}0 qNWqW| r| j( j) d,  | j* j) d;  | j+ g   | j, d. j- d;  | j, d1 j- d;  | j, d4 j- d;  | j, d, j. d< d0 |# f  | j/ d d  | j* j0 |2  | j1 d= t d> t  n | j* j) d.  | j( j) d;  | j2 g   | j, d, j- d;  | j, d1 j- d;  | j, d4 j- d;  | j, d. j. d< d0 |" f  | j3 d d  | j( j0 |2  | j1 d? t d> t  | S(I   s  
    Produce a dotplot similar in style to those in Cleveland's
    "Visualizing Data" book.  These are also known as "forest plots".

    Parameters
    ----------
    points : array_like
        The quantitative values to be plotted as markers.
    intervals : array_like
        The intervals to be plotted around the points.  The elements
        of `intervals` are either scalars or sequences of length 2.  A
        scalar indicates the half width of a symmetric interval.  A
        sequence of length 2 contains the left and right half-widths
        (respectively) of a nonsymmetric interval.  If None, no
        intervals are drawn.
    lines : array_like
        A grouping variable indicating which points/intervals are
        drawn on a common line.  If None, each point/interval appears
        on its own line.
    sections : array_like
        A grouping variable indicating which lines are grouped into
        sections.  If None, everything is drawn in a single section.
    styles : array_like
        A grouping label defining the plotting style of the markers
        and intervals.
    marker_props : dict
        A dictionary mapping style codes (the values in `styles`) to
        dictionaries defining key/value pairs to be passed as keyword
        arguments to `plot` when plotting markers.  Useful keyword
        arguments are "color", "marker", and "ms" (marker size).
    line_props : dict
        A dictionary mapping style codes (the values in `styles`) to
        dictionaries defining key/value pairs to be passed as keyword
        arguments to `plot` when plotting interval lines.  Useful
        keyword arguments are "color", "linestyle", "solid_capstyle",
        and "linewidth".
    split_names : string
        If not None, this is used to split the values of `lines` into
        substrings that are drawn in the left and right margins,
        respectively.  If None, the values of `lines` are drawn in the
        left margin.
    section_order : array_like
        The section labels in the order in which they appear in the
        dotplot.
    line_order : array_like
        The line labels in the order in which they appear in the
        dotplot.
    stacked : boolean
        If True, when multiple points or intervals are drawn on the
        same line, they are offset from each other.
    styles_order : array_like
        If stacked=True, this is the order in which the point styles
        on a given line are drawn from top to bottom (if horizontal
        is True) or from left to right (if horiontal is False).  If
        None (default), the order is lexical.
    striped : boolean
        If True, every other line is enclosed in a shaded box.
    horizontal : boolean
        If True (default), the lines are drawn horizontally, otherwise
        they are drawn vertically.
    show_names : string
        Determines whether labels (names) are shown in the left and/or
        right margins (top/bottom margins if `horizontal` is True).
        If `both`, labels are drawn in both margins, if 'left', labels
        are drawn in the left or top margin.  If `right`, labels are
        drawn in the right or bottom margin.
    fmt_left_name : function
        The left/top margin names are passed through this function
        before drawing on the plot.
    fmt_right_name : function
        The right/bottom marginnames are passed through this function
        before drawing on the plot.
    show_section_titles : bool or None
        If None, section titles are drawn only if there is more than
        one section.  If False/True, section titles are never/always
        drawn, respectively.
    ax : matplotlib.axes
        The axes on which the dotplot is drawn.  If None, a new axes
        is created.

    Returns
    -------
    fig : Figure
        The figure given by `ax.figure` or a new instance.

    Notes
    -----
    `points`, `intervals`, `lines`, `sections`, `styles` must all have
    the same length whenever present.

    Examples
    --------
    This is a simple dotplot with one point per line:
    >>> dot_plot(points=point_values)

    This dotplot has labels on the lines (if elements in
    `label_values` are repeated, the corresponding points appear on
    the same line):
    >>> dot_plot(points=point_values, lines=label_values)

    References
    ----------
      * Cleveland, William S. (1993). "Visualizing Data". Hobart
        Press.
      * Jacoby, William G. (2006) "The Dot Plot: A Graphical Display
        for Labeled Quantitative Values." The Political Methodologist
        14(1): 6-14.
    iNc         S   s   |  d  k r d  St j |   S(   N(   t   Nonet   npt   asarray(   t   x(    (    s<   lib/python2.7/site-packages/statsmodels/graphics/dotplots.pyt   <lambda>   t    g      ?i    i   g{Gz?g      @g        c            s"   i  |  ] }   j  |  |  q S(    (   t   index(   t   .0R   (   t   style_codes(    s<   lib/python2.7/site-packages/statsmodels/graphics/dotplots.pys
   <dictcomp>   s   	 t   rt   gt   bt   yt   kt   purplet   orangec         S   s   i  |  ] } i  |  q S(    (    (   R
   R   (    (    s<   lib/python2.7/site-packages/statsmodels/graphics/dotplots.pys
   <dictcomp>   s   	 t   colort   markert   ot   msi
   i   c         S   s   i  |  ] } i  |  q S(    (    (   R
   R   (    (    s<   lib/python2.7/site-packages/statsmodels/graphics/dotplots.pys
   <dictcomp>  s   	 t   greyt	   linewidthi   i   gffffff?t   darkgreyt	   transformt   zordergffffff?t   horizontalalignmentt   centert   verticalalignmentt   boldg{Gz?g)\(?g(\?t   clip_ongRQ?t   bottomt	   lightgreyt   leftR   gt   rightt   familyt	   monospacet   topg?i   t   -t   lsR   t   labelt   nonet   axest   scaleyt   tightt   scalex(   i    i   (   i    i   (   g)\(?g)\(?(   g(\?g(\?(   i    i   (   i    i    (   i   i   (   R#   R   (   R$   R   (4   t   matplotlib.transformst
   transformsR   t   create_mpl_axR   R   t   lenR   t   aranget   zerost   sett   Falset   Truet   set_xmargint   set_ymargint   listt   sortR    t   appendt   get_window_extentt   transformedt   dpi_scale_transt   invertedt   widtht   heightt   blended_transform_factoryt	   transDatat	   transAxest   floatt   fill_betweent   textt   set_fontweightt   axhlinet   axvlinet   splitt   lowert	   enumeratet   isscalart   plott   addt   xaxist   set_ticks_positiont   yaxist   set_yticklabelst   spinest	   set_colort   set_positiont   set_ylimt	   set_tickst   autoscale_viewt   set_xticklabelst   set_xlim(E   t   pointst	   intervalst   linest   sectionst   stylest   marker_propst
   line_propst   split_namest   section_ordert
   line_ordert   stackedt   styles_ordert   stripedt
   horizontalt
   show_namest   fmt_left_namet   fmt_right_namet   show_section_titlest   axR1   t   figt   asarray_or_nonet   npointt   section_title_spacet   nsectt   draw_section_titlest   nsect_titlet   section_space_totalt   lines0t   lines1t	   lines_mapt   it   kyt   bboxt   awidtht   aheightt   nrowsR!   R'   t   transt   title_space_axest   dpost   nvalt   stackdt   style_codes_mapt   colorst   jt   sct   post   labeledt   tickst   k0t   y0t   txtR   t   mt   jrowt   k1t   ust
   left_labelt   right_labelt   jit   jpt   yot   ptt   lcbt   ucbt   slt   sll(    (   R   s<   lib/python2.7/site-packages/statsmodels/graphics/dotplots.pyt   dot_plot   s   t			

	

'
'#	$	/		""	
		

	
	
	
	#
&&
		(
   t   numpyR   t   statsmodels.compatR    R   R   R   R7   R8   R   (    (    (    s<   lib/python2.7/site-packages/statsmodels/graphics/dotplots.pyt   <module>   s   				