ó
jÜxec           @   s  d  d l  m Z d  d l Z d  d l Z d  d l Z e j d d k rc d  d l Z e j	 d ƒ n  d  d l
 j Z d  d l m Z d  d l m Z d  d l m Z d  d	 l m Z d  d
 l m Z m Z d  d l m Z m Z d  d l m Z d d d „  ƒ  YZ d S(   iÿÿÿÿ(   t   divisionNi    i   t   TkAgg(   t	   Rectangle(   t   Axes(   t   Glyph(   t   validate_matrix(   t   checkt   handle_errors(   t   get_color_dictt   get_rgb(   t   transform_matrixt   Logoc           B   sO  e  Z d  Z e d! d d e d e d d e d d d d! d! d d" d	 „ ƒ Z d
 „  Z e d! d „ ƒ Z	 e d d d „ ƒ Z
 e d! d! d d d! d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d d d! d! d! d d „ ƒ Z e d d d d „ ƒ Z e d d d d d „ ƒ Z e d# e d d d! d „ ƒ Z e d „ Z d  „  Z RS($   ss  
    Logo represents a basic logo, drawn on a specified axes object
    using a specified matrix, which is supplied as a pandas dataframe.

    attributes
    ----------

    df: (pd.DataFrame)
        A matrix specifying character heights and positions. Rows correspond
        to positions while columns correspond to characters. Column names
        must be single characters and row indices must be integers.

    color_scheme: (str, dict, or array with length 3)
        Specification of logo colors. Default is 'gray'. Can take a variety of
        forms.
         - (str) A built-in Logomaker color scheme in which the color of each
         character is determined that character's identity. Options are,
             + For DNA/RNA: 'classic', 'grays', or 'base_paring'.
             + For protein: 'hydrophobicity', 'chemistry', or 'charge'.
         - (str) A built-in matplotlib color name such as 'k' or 'tomato'
         - (list) An RGB array, i.e., 3 floats with values in the interval [0,1]
         - (dict) A dictionary that maps characters to colors, E.g.,
            {'A': 'blue',
             'C': 'yellow',
             'G': 'green',
             'T': 'red'}

    font_name: (str)
        The character font to use when rendering the logo. For a list of
        valid font names, run logomaker.list_font_names().

    stack_order: (str)
        Must be 'big_on_top', 'small_on_top', or 'fixed'. If 'big_on_top',
        stack characters away from x-axis in order of increasing absolute value.
        If 'small_on_top', stack glyphs away from x-axis in order of
        decreasing absolute value. If 'fixed', stack glyphs from top to bottom
        in the order that characters appear in the data frame.

    center_values: (bool)
        If True, the stack of characters at each position will be centered
        around zero. This is accomplished by subtracting the mean value
        in each row of the matrix from each element in that row.

    baseline_width: (float >= 0.0)
        Width of the logo baseline, drawn at value 0.0 on the y-axis.

    flip_below: (bool)
        If True, characters below the x-axis (which correspond to negative
        values in the matrix) will be flipped upside down.

    shade_below: (float in [0,1])
        The amount of shading to use for characters drawn below the x-axis.
        Larger numbers correspond to more shading (i.e., darker characters).

    fade_below: (float in [0,1])
        The amount of fading to use for characters drawn below the x-axis.
        Larger numbers correspond to more fading (i.e., more transparent
        characters).

    fade_probabilities: (bool)
        If True, the characters in each stack will be assigned an alpha value
        equal to their height. This option only makes sense if df is a
        probability matrix. For additional customization, use
        Logo.fade_glyphs_in_probability_logo().

    vpad: (float in [0,1])
        The whitespace to leave above and below each character within that
        character's bounding box. Note that, if vpad > 0, the height of the
        character's bounding box (and not of the character itself) will
        correspond to values in df.

    vsep: (float >= 0)
        Amount of whitespace to leave between the bounding boxes of rendered
        characters. Unlike vpad, vsep is NOT relative to character height.

    alpha: (float in [0,1])
        Opacity to use when rendering characters. Note that, if this is used
        together with fade_below or fade_probabilities, alpha will multiply
        existing opacity values.

    show_spines: (None or bool)
        Whether a box should be drawn around the logo.  For additional
        customization of spines, use Logo.style_spines().

    ax: (matplotlib Axes object)
        The matplotlb Axes object on which the logo is drawn.

    zorder: (int >=0)
        This governs what other objects drawn on ax will appear in front or
        behind the rendered logo.

    figsize: ([float, float]):
        The default figure size for the rendered logo; only used if ax is
        not supplied by the user.

    **kwargs:
        Additional key word arguments to send to the Glyph constructor.
    t   sanst
   big_on_topg      à?g        g      ð?i    i
   g      @c         K   s  | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ |
 |  _	 | |  _
 | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ t |  _ |  j ƒ  t |  j  ƒ |  _ t j g  |  j  j D] } | ^ qÚ ƒ |  _ t |  j ƒ |  _ t |  j |  j ƒ |  _ t j g  |  j  j D] } | ^ q/ƒ |  _ |  j rkt  |  j  d t! ƒ|  _  n  |  j d  k r§t# j$ d d d |  j ƒ\ } } | |  _ n  | j% |  _& |  j' ƒ  |  j( d |  j d |  j d |  j ƒ |  j	 r|  j) d d d	 d ƒ n  |  j* ƒ  d  S(
   Nt   center_valuesi   t   figsizet   shadet   fadet   flipt   v_alpha0i    t   v_alpha1(+   t   dft   color_schemet	   font_namet   stack_orderR   t   baseline_widtht
   flip_belowt   shade_belowt
   fade_belowt   fade_probabilitiest   vpadt   vsept   alphat   show_spinest   zorderR   t   axt   glyph_kwargst   Falset   has_been_drawnt   _input_checkst   lent   Lt   npt   arrayt   columnst   cst   CR   t   rgb_dictt   indext   psR
   t   Truet   Nonet   pltt   subplotst   figuret   figt   _compute_glyphst   style_glyphs_belowt   fade_glyphs_in_probability_logot   draw(   t   selfR   R   R   R   R   R   R   R   R   R   R   R   R    R!   R#   R"   R   t   kwargst   ct   pR7   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   __init__|   sN    																			
++	!
	
	
c         C   sô  t  |  j ƒ |  _ t t |  j t ƒ d t |  j ƒ ƒ d d d h } t |  j | k d |  j | f ƒ t t |  j t	 ƒ d t |  j ƒ ƒ t t |  j
 t t f ƒ d t |  j
 ƒ ƒ t |  j
 d k d	 |  j
 ƒ t t |  j t	 ƒ d
 t |  j ƒ ƒ t t |  j t t f ƒ d t |  j ƒ ƒ t d |  j k oHd k n d ƒ t t |  j t t f ƒ d t |  j ƒ ƒ t d |  j k ošd k n d ƒ t t |  j t	 ƒ d t |  j ƒ ƒ t t |  j t t f ƒ d t |  j ƒ ƒ t d |  j k od k n d ƒ t t |  j t t f ƒ d t |  j ƒ ƒ t |  j d k d |  j ƒ t t |  j t t f ƒ d t |  j ƒ ƒ t d |  j k o­d k n d ƒ t t |  j t	 ƒ p×|  j d k d t |  j ƒ ƒ t t |  j t ƒ p|  j d k d t |  j ƒ ƒ t t |  j t t f ƒ d t |  j ƒ ƒ t t |  j t t t j f ƒ d t |  j ƒ ƒ t |  j ƒ |  _ t t |  j ƒ d k d ƒ t t  g  |  j D]' } t | t t f ƒ oà| d k ^ q¼ƒ d ƒ d S(    s   
        Validate parameters passed to the Logo constructor EXCEPT for
        color_scheme; that is validated in the Logo constructor
        s(   type(font_name) = %s must be of type strR   t   small_on_topt   fixeds    stack_order = %s; must be in %s.s/   type(center_values) = %s; must be of type bool.s0   type(baseline_width) = %s must be of type numberg        s"   baseline_width = %s must be >= 0.0s,   type(flip_below) = %s; must be of type bool s,   type(shade_below) = %s must be of type floatg      ð?s#   shade_below must be between 0 and 1s+   type(fade_below) = %s must be of type floats"   fade_below must be between 0 and 1s4   type(fade_probabilities) = %s; must be of type bool s%   type(vpad) = %s must be of type floats   vpad must be between 0 and 1s.   type(vsep) = %s; must be of type float or int i    s!   vsep = %d must be greater than 0 s&   type(alpha) = %s must be of type floats   alpha must be between 0 and 1s6   show_spines = %s; show_spines must be None or boolean.s5   ax = %s; ax must be None or a matplotlib.Axes object.s+   type(zorder) = %s; zorder must be a number.s/   type(figsize) = %s; figsize must be array-like.i   s   figsize must have length two.s2   all elements of figsize array must be numbers > 0.N(!   R   R   R   t
   isinstanceR   t   strt   typeR   R   t   boolR   t   intt   floatR   R   R   R   R   R   R    R!   R3   t   reprR#   R   R"   R   t   tuplet   listR*   t   ndarrayR(   t   all(   R<   t   valid_stack_orderst   n(    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyR'   Ù   sv    &&!!	4c         K   s¸   | d k	 r0 | |  _ t |  j |  j ƒ |  _ n  x= d d d g D], } | | j ƒ  k r@ | | |  j | <q@ q@ WxA |  j D]6 } | d k	 r£ |  j | j | d <n  | j	 |   qz Wd S(   s&  
        Modifies the properties of all characters in a Logo.

        parameters
        ----------

        color_scheme: (str, dict, or array with length 3)
            Specification of logo colors. Default is 'gray'. Can take a variety of
            forms.
             - (str) A built-in Logomaker color scheme in which the color of each
             character is determined that character's identity. Options are,
                 + For DNA/RNA: 'classic', 'grays', or 'base_paring'.
                 + For protein: 'hydrophobicity', 'chemistry', or 'charge'.
             - (str) A built-in matplotlib color name such as 'k' or 'tomato'
             - (list) An RGB array, i.e., 3 floats with values in the interval [0,1]
             - (dict) A dictionary that maps characters to colors, E.g.,
                {'A': 'blue',
                 'C': 'yellow',
                 'G': 'green',
                 'T': 'red'}

        **kwargs:
            Keyword arguments to pass to Glyph.set_attributes()

        returns
        -------
        None
        R"   R   R   t   colorN(
   R3   R   R   R-   R/   t   keyst   __dict__t
   glyph_listR>   t   set_attributes(   R<   R   R=   t   keyt   g(    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   style_glyphsL  s    $	c         C   ss  t  t | t t f ƒ d t | ƒ ƒ t  d | k o@ d k n d | ƒ t  t | t t f ƒ d t | ƒ ƒ t  d | k o d k n d | ƒ t  | | k  d | | f ƒ t |  j d d	 ƒ|  _ x |  j D]’ } x‰ |  j D]~ } |  j j	 | | f } |  j
 j	 | | f } | | k r0d
 } n' | | k rEd } n | | | | } | j d | ƒ qé WqÙ Wd S(   sv  
        Fades glyphs in probability logo according to value.

        parameters
        ----------

        v_alpha0, v_alpha1: (number in [0,1])
            Matrix values marking values that are rendered using
            alpha=0 and alpha=1, respectively. These values must satisfy
            v_alpha0 < v_alpha1.

        returns
        -------
        None
         s$   type(v_alpha0) = %s must be a numberg        g      ð?s.   v_alpha0 must be between 0 and 1; value is %f.s$   type(v_alpha1) = %s must be a numbers-   v_alpha1 must be between 0 and 1; value is %fsC   must have v_alpha0 < v_alpha1;here, v_alpha0 = %f and v_alpha1 = %ft   matrix_typet   probabilityi    i   R    N(   R   RC   RH   RG   RE   R   R   R1   R-   t   loct   glyph_dfRT   (   R<   R   R   R?   R>   t   vRV   R    (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyR:   ƒ  s0    		c      
   K   s#  | d k	 r t | ƒ } n  | d k	 r‚ t t | t t f ƒ d t | ƒ ƒ t | ƒ |  _ t d | k ov d k n d ƒ n  t t | t t f ƒ d t | ƒ ƒ t d | k oÂ d k n d | ƒ t t | t t f ƒ d t | ƒ ƒ t d | k od k n d	 | ƒ | d k	 rKt t | t ƒ d
 t | ƒ ƒ n  xÑ |  j	 D]Æ } x½ |  j
 D]² } |  j j | | f }	 |	 d k  re|  j j | | f }
 | d k rÁt |
 j ƒ } n | } | d k rß|
 j } n | } |
 j d | d | d | d | d | |  qeqeWqUWd S(   s  
        Modifies the properties of all characters drawn below the x-axis.

        parameters
        ----------

        color: (color specification)
            Color to use before shade is applied.

        alpha: (number in [0,1])
            Opacity to use when rendering characters, before fade is applied.

        shade: (number in [0,1])
            The amount to shade characters below the x-axis.

        fade: (number in [0,1])
            The amount to fade characters below the x-axis.

        flip: (bool)
            If True, characters below the x-axis will be flipped upside down.

        **kwargs:
            Keyword arguments to pass to Glyph.set_attributes(), but only
            for characters below the x-axis.

        returns
        -------
        None
        s'   type(alpha) = %s must be a float or inti    g      ð?s-   alpha must be between 0.0 and 1.0 (inclusive)s!   type(shade) = %s must be a numberg        s+   shade must be between 0 and 1; value is %f.s    type(fade) = %s must be a numbers)   fade must be between 0 and 1; value is %fs&   type(flip) = %s; must be of type bool RP   R    R   N(   R3   R	   R   RC   RH   RG   RE   R    RF   R1   R-   R   RZ   R[   RP   RT   (   R<   RP   R    R   R   R   R=   R?   R>   R\   RV   t
   this_colort
   this_alpha(    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyR9   Å  sL    (
c         K   sÄ   t  t | t ƒ d t | ƒ ƒ t  | |  j j k d | ƒ t  t | t ƒ d t | ƒ ƒ t  t | ƒ d k d t | ƒ ƒ t  | |  j j	 k d | ƒ |  j j
 | | f } | j |   d S(   s  
        Modifies the properties of a single character in Logo.

        parameters
        ----------

        p: (int)
            Position of modified glyph. Must index a row in the matrix df passed
            to the Logo constructor.

        c: (str of length 1)
            Character to modify. Must be the name of a column in the matrix df
            passed to the Logo constructor.

        **kwargs:
            Keyword arguments to pass to Glyph.set_attributes()

        returns
        -------
        None
        s    type(p) = %s must be of type ints   p=%s is not a valid positions    type(c) = %s must be of type stri   s   c = %s; must have length 1.s   c=%s is not a valid characterN(   R   RC   RG   RE   R[   R0   RD   R(   RI   R,   RZ   RT   (   R<   R?   R>   R=   RV   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   style_single_glyph1  s    c         K   s§   t  t | t ƒ d t | ƒ ƒ t  t | ƒ |  j k d t | ƒ d |  j ƒ xO t |  j j ƒ D]; \ } } | | } | |  j	 k rd |  j
 | | |  qd qd Wd S(   sÐ  
        Restyles the glyphs in a specific sequence.

        parameters
        ----------
        sequence: (str)
            A string the same length as the logo, specifying which character
            to restyle at each position. Characters in sequence that are not
            in the columns of the Logo's df are ignored.

        **kwargs:
            Keyword arguments to pass to Glyph.set_attributes()

        returns
        -------
        None
        s'   type(sequence) = %s must be of type strs    sequence to restyle (length %d) s*   must have same length as logo (length %d).N(   R   RC   RD   RE   R(   R)   t	   enumerateR[   R0   R-   R_   (   R<   t   sequenceR=   t   iR?   R>   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   style_glyphs_in_sequencec  s    
c         K   s=   t  t | t ƒ d t | ƒ ƒ |  j d | d | |  d S(   s1  
        Draws a rectangular box highlighting a specific position.

        parameters
        ----------
        p: (int)
            Single position to highlight.

        **kwargs:
            Other parameters to pass to highlight_position_range()

        returns
        -------
        None
        s    type(p) = %s must be of type intt   pmint   pmaxN(   R   RC   RG   RE   t   highlight_position_range(   R<   R?   R=   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   highlight_position  s    t   yellowiþÿÿÿc	         K   s  |  j  j ƒ  \ }
 } t t | t t f ƒ d t | ƒ ƒ t t | t t f ƒ d t | ƒ ƒ t | | k d ƒ t t | t t f ƒ o• | d k d t | ƒ ƒ | d k	 rÁ t	 | ƒ } n  | d k	 rÜ t	 | ƒ } n  | d k rñ |
 } n& t t | t t f ƒ d t | ƒ ƒ | d k r,| } n& t t | t t f ƒ d t | ƒ ƒ t | | k d | | f ƒ t t | t t f ƒ d	 t | ƒ ƒ | d
 | } | } | | d d | } | | } t
 d | | f d | d | d | d | d | |	  } |  j  j | ƒ d S(   s  
        Draws a rectangular box highlighting multiple positions within the Logo

        parameters
        ----------
        pmin: (int)
            Lowest position to highlight.
            
        pmax: (int)
            Highest position to highlight.
            
        padding: (number >= -0.5)
            Amount of padding to add on the left and right sides of highlight.
            
        color: (None or matplotlib color)
            Color to use for highlight. Can be a named matplotlib color or
            an RGB array.

        edgecolor: (None or matplotlib color)
            Color to use for highlight box edges. Can be a named matplotlib
            color or an RGB array.
            
        floor: (None number)
            Lowest y-axis extent of highlight box. If None, is set to
            ymin of the Axes object.
            
        ceiling: (None or number)
            Highest y-axis extent of highlight box. If None, is set to
            ymax of the Axes object.
            
        zorder: (number)
            This governs which other objects drawn on ax will appear in front or
            behind of the highlight. Logo characters are, by default, drawn in
            front of the highlight box.

        returns
        -------
        None
        s    type(pmin) = %s must be a numbers    type(pmax) = %s must be a numbers   pmin <= pmax not satisfied.g      à¿s%   padding = %s must be a number >= -0.5s!   type(floor) = %s must be a numbers#   type(ceiling) = %s must be a numbers;   must have floor <= ceiling; as is, floor = %f, ceiling = %ss'   type(zorder) = %s; must a float or int.g      à?i   i   t   xyt   widtht   heightt	   facecolort	   edgecolorR"   N(   R#   t   get_ylimR   RC   RH   RG   RE   RI   R3   R	   R   t	   add_patch(   R<   Rd   Re   t   paddingRP   Rm   t   floort   ceilingR"   R=   t   ymint   ymaxt   xt   yRj   Rk   t   patch(    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyRf   «  sL    4!		
	iÿÿÿÿt   blackc         K   s‘   t  t | t t f ƒ d t | ƒ ƒ t | ƒ } t  t | t t f ƒ d t | ƒ ƒ t  | d k d ƒ |  j j d | d | d | |  d S(	   s‘  
        Draws a horizontal line along the x-axis.

        parameters
        ----------

        zorder: (number)
            This governs what other objects drawn on ax will appear in front or
            behind the baseline. Logo characters are, by default, drawn in front
            of the baseline.

        color: (matplotlib color)
            Color to use for the baseline. Can be a named matplotlib color or an
            RGB array.

        linewidth: (number >= 0)
            Width of the baseline.

        **kwargs:
            Additional keyword arguments to be passed to ax.axhline()

        returns
        -------
        None
        s'   type(zorder) = %s; must a float or int.s'   type(linewidth) = %s; must be a number i    s   linewidth must be >= 0R"   RP   t	   linewidthN(   R   RC   RH   RG   RE   R	   R#   t   axhline(   R<   R"   RP   Ry   R=   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   draw_baseline"  s    !i   s   %dc         K   s(  t  t | t ƒ d t | ƒ ƒ t  t | t ƒ o; | d k d t | ƒ ƒ t  t | t ƒ d t | ƒ ƒ t  t | t t f ƒ d t | ƒ ƒ t |  j ƒ } t	 |  j ƒ } t
 j | | d ƒ } | | | | d k }	 |  j j |	 ƒ g  |	 D] }
 | |
 ^ qõ } |  j j | d | | d S(	   s©  
        Formats and styles tick marks along the x-axis.

        parameters
        ----------

        anchor: (int)
            Anchors tick marks at a specific number. Even if this number
            is not within the x-axis limits, it fixes the register for
            tick marks.

        spacing: (int > 0)
            The spacing between adjacent tick marks

        fmt: (str)
            String used to format tick labels.

        rotation: (number)
            Angle, in degrees, with which to draw tick mark labels.

        **kwargs:
            Additional keyword arguments to be passed to ax.set_xticklabels()

        returns
        -------
        None
        s%   type(anchor) = %s must be of type inti    s   spacing = %s must be an int > 0s"   type(fmt) = %s must be of type strs2   type(rotation) = %s; must be of type float or int i   t   rotationN(   R   RC   RG   RE   RI   RD   RH   t   minR1   t   maxR*   t   arangeR#   t
   set_xtickst   set_xticklabels(   R<   t   anchort   spacingt   fmtR|   R=   t   p_mint   p_maxR1   t   xticksR?   t   xticklabels(    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   style_xticksV  s     $t   topt   bottomt   leftt   rightc         C   s*  d |  _ t t | t t t f ƒ d t | ƒ ƒ t | ƒ } d d d d h } t | | k d t | ƒ ƒ t t | t	 ƒ d t | ƒ ƒ t t | t
 t f ƒ d t | ƒ ƒ t | d	 k d
 ƒ t | ƒ } | d k	 r¦t t t j f } t t | | ƒ d t | ƒ | f ƒ t t | ƒ d k d t | ƒ d f ƒ t t g  | D] } t | t
 t f ƒ ^ qLƒ d t | ƒ ƒ t | d	 | d k  d t | ƒ ƒ n  x} |  j j j ƒ  D]i \ }	 }
 |	 | k r¹|
 j | ƒ |
 j | ƒ |
 j | ƒ | d k	 r"|
 j | d	 | d ƒ q"q¹q¹Wd S(   sq  
        Styles the spines of the Axes object in which the logo is drawn.
        Note: "spines" refers to the edges of the Axes bounding box.

        parameters
        ----------

        spines: (tuple of str)
            Specifies which of the four spines to modify. The default value
            for this parameter lists all four spines.

        visible: (bool)
            Whether to show or not show the spines listed in the parameter
            spines.

        color: (matplotlib color)
            Color of the spines. Can be a named matplotlib color or an
            RGB array.

        linewidth: (float >= 0)
            Width of lines used to draw the spines.

        bounds: (None or [float, float])
            If not None, specifies the values between which a spine (or spines)
            will be drawn.

        returns
        -------
        None
        s6   type(spines) = %s; must be of type (tuple, list, set) RŠ   R‹   RŒ   R   s/   spines has invalid entry; valid entries are: %ss)   type(visible) = %s; must be of type bool s'   type(linewidth) = %s; must be a number i    s   linewidth must be >= 0s$   type(bounds) = %s; must be one of %si   s   len(bounds) = %d; must be %ds(   bounds = %s; all entries must be numbersi   s,   bounds = %s; must have bounds[0] < bounds[1]N(   R3   R!   R   RC   RJ   RK   t   setRE   RI   RF   RH   RG   R	   R*   RL   R(   RM   R#   t   spinest   itemst   set_visiblet	   set_colort   set_linewidtht
   set_bounds(   R<   R   t   visibleRP   Ry   t   boundst   valid_spinest   bounds_typest   boundt   namet   spine(    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   style_spines—  sD    (	.c         C   sf  t  t | t ƒ d t | ƒ ƒ | rT |  j j ƒ  x |  j D] } | j ƒ  q= Wn  |  j d |  j	 ƒ t
 g  |  j D] } | j d | j ^ qt ƒ } t g  |  j D] } | j d | j ^ q¤ ƒ } |  j j | | g ƒ t
 g  |  j D] } | j ^ qê ƒ } t g  |  j D] } | j ^ qƒ } |  j j | | g ƒ |  j d k	 rb|  j d |  j ƒ n  d S(   s×   
        Draws characters in Logo.

        parameters
        ----------

        clear: (bool)
            If True, Axes will be cleared before logo is drawn.

        returns
        -------
        None
        s'   type(clear) = %s; must be of type bool Ry   g      à?R•   N(   R   RC   RF   RE   R#   t   clearRS   R;   R{   R   R}   R?   Rj   R~   t   set_xlimRq   Rr   t   set_ylimR!   R3   Rœ   (   R<   R   RV   t   xmint   xmaxRs   Rt   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyR;   ÿ  s     00%%c         C   sn  t  j ƒ  } x|  j D]} t j |  j j | d d … f ƒ } |  j d k rb t j | ƒ } n  |  j d k r¶ t j	 t
 | ƒ ƒ } | d k } d | | | | <t j | ƒ } nL |  j d k rð t j t t
 | ƒ ƒ ƒ d d d … } n t st d ƒ ‚ | | } g  |  j | D] } t | ƒ ^ q} t | |  j | d k  ƒ |  j d	 }	 xÉ t | | ƒ D]¸ \ }
 } |	 t |
 ƒ } |  j | } |
 d k  o¥|  j } t | | d
 |  j d |	 d | d | d | d |  j d |  j d |  j d |  j |  j 	} | | j | | f <| |  j }	 qjWq W| |  _ g  |  j j j ƒ  D] } t  | t ƒ rF| ^ qF|  _! d S(   sT   
        Specifies the placement and styling of all glyphs within the logo.
        NR   RA   i    g      ð?RB   iÿÿÿÿs)   This line of code should never be called.g       @R#   Rq   Rr   RP   R   R"   R   R    R   ("   t   pdt	   DataFrameR1   R*   R+   R   RZ   R   t   argsortt   zerosR(   t   rangeR%   t   AssertionErrorR-   RD   t   sumR   t   zipt   absR/   R   R   R#   R"   R   R    R   R$   R[   t   valuest   ravelRC   RS   (   R<   R[   R?   t   vst   ordered_indicest   tmp_vst   indicesR>   R-   Rq   R\   Rr   R]   R   t   glyphRV   (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyR8   ,  sH    %+
&(					N(   i
   g      @(   RŠ   R‹   RŒ   R   (   t   __name__t
   __module__t   __doc__R   R3   R%   R2   R@   R'   RW   R:   R9   R_   Rc   Rg   Rf   R{   R‰   Rœ   R;   R8   (    (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyR      sr   bK	s5?f2*n0<b-(    (   t
   __future__R    t   numpyR*   t   pandasR¢   t   syst   version_infot
   matplotlibt   uset   matplotlib.pyplott   pyplotR4   t   matplotlib.patchesR   t   matplotlib.axesR   t   logomaker.src.GlyphR   t   logomaker.src.validateR   t   logomaker.src.error_handlingR   R   t   logomaker.src.colorsR   R	   t   logomaker.src.matrixR
   R   (    (    (    s7   /tmp/pip-install-l3LICk/logomaker/logomaker/src/Logo.pyt   <module>   s   