B
    ]”t\"_  ã               @   s4  d Z ddlZddlZddlZddlZddlZddlZe 	e
¡Zdd„ ZG dd„ deƒZd7dd	„Zd8d
d„Zd9dd„Zd:dd„Zd;dd„Zd<dd„Zd=dd„Zd>dd„Zd?dd„Zd@dd„ZdAdd„ZdBd d!„ZdCd"d#„ZdDd$d%„ZdEd&d'„ZdFd(d)„Ze ¡ a d*d+„ Z!d,d-„ Z"d.d/„ Z#d0d1„ Z$d2d3„ Z%dGd5d6„Z&dS )HaX  

Conventions:

"constrain_x" means to constrain the variable with either
another kiwisolver variable, or a float.  i.e. `constrain_width(0.2)`
will set a constraint that the width has to be 0.2 and this constraint is
permanent - i.e. it will not be removed if it becomes obsolete.

"edit_x" means to set x to a value (just a float), and that this value can
change.  So `edit_width(0.2)` will set width to be 0.2, but `edit_width(0.3)`
will allow it to change to 0.3 later.  Note that these values are still just
"suggestions" in `kiwisolver` parlance, and could be over-ridden by
other constrains.

é    Nc             C   sV   | j r| j }nD| j}|r,t|dƒr,| ¡ }n&t d¡ ddlm} || ƒ}| ¡ }|S )NÚget_rendererz1constrained_layout : falling back to Agg rendererr   )ÚFigureCanvasAgg)Z_cachedRendererÚcanvasÚhasattrr   Ú_logÚinfoZmatplotlib.backends.backend_aggr   )ÚfigZrendererr   r   © r	   ú4lib/python3.7/site-packages/matplotlib/_layoutbox.pyr      s    

r   c               @   sT  e Zd ZdZdPdd„Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdQdd„ZdRdd„ZdSdd„Zd d!„ ZdTd"d#„Zd$d%„ ZdUd&d'„Zd(d)„ ZdVd*d+„Zd,d-„ Zd.d/„ Zd0d1„ ZdWd2d3„ZdXd4d5„ZdYd6d7„ZdZd8d9„Zd[d:d;„Zd\d<d=„Zd]d>d?„Zd^d@dA„Z d_dBdC„Z!d`dDdE„Z"dFdG„ Z#dHdI„ Z$dJdK„ Z%dadLdM„Z&dNdO„ Z'dS )bÚ	LayoutBoxzD
    Basic rectangle representation using kiwi solver variables
    NÚ F©r   r   ©é   r   c             C   s  t j}|| _|| _| jd }|d kr6t  ¡ | _d| _n|j| _d | _| | ¡ || _|| _	|	| _
|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d	 ƒƒ| _|t|d
 ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|t|d ƒƒ| _|\}}|\}}|| _ || _!|  "¡  g | _#d | _$| j	r|  %¡  |
| _&|| _'d S )NÚ_r   ÚtopÚbottomÚleftÚrightÚwidthÚheightÚh_centerÚv_centerÚ	min_widthÚ
min_heightÚ
pref_widthÚpref_heightÚleft_marginÚright_marginÚbottom_marginÚ
top_marginÚleft_margin_minÚright_margin_minÚbottom_margin_minÚtop_margin_min)(ÚkiwiÚVariableÚparentÚnameZSolverÚsolverZconstrained_layout_calledÚ	add_childÚartistÚposÚsubplotÚstrr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   ÚtightheightÚ
tightwidthÚadd_constraintsÚchildrenZsubplotspecÚconstrain_marginsÚh_padÚw_pad)Úselfr'   r(   r0   r/   r+   Z
lower_leftZupper_rightr,   r-   r4   r5   r&   Zsnr   r   r   r   r	   r	   r
   Ú__init__5   sX    


zLayoutBox.__init__c             C   s¬  | j }| | j¡s.| | jd¡ | | jd¡ | j| j| jj k}| j  |dB ¡ | j| jk}| j  |dB ¡ | | j	¡s–| | j	d¡ | | j	d¡ | j
| jj| j k}| j  |dB ¡ | j
| j	k}| j  |dB ¡ | | j¡sþ| | jd¡ | | jd¡ | j| j| jj k}| j  |dB ¡ | j| jk}| j  |dB ¡ | | j¡sh| | jd¡ | | jd¡ | j| jj| j k}| j  |dB ¡ | j| jk}| j  |dB ¡ dS )a’  
        Only do this for pos.  This sets a variable distance
        margin between the position of the axes and the outer edge of
        the axes.

        Margins are variable because they change with the fogure size.

        Margin minimums are set to make room for axes decorations.  However,
        the margins can be larger if we are mathicng the position size to
        otehr axes.
        Ústrongg-Cëâ6?ÚrequiredN)r)   ÚhasEditVariabler!   ÚaddEditVariableÚsuggestValuer   r   r'   ÚaddConstraintr"   r   r   r#   r   r   r$   r    r   )r6   ÚsolÚcr	   r	   r
   r3   t   s:    zLayoutBox.constrain_marginsc             C   s   |  j |g7  _ d S )N)r2   )r6   Úchildr	   r	   r
   r*   ¤   s    zLayoutBox.add_childc             C   s4   y| j  |¡ W n tk
r.   t d¡ Y nX d S )Nz3Tried to remove child that doesn't belong to parent)r2   ÚremoveÚ
ValueErrorr   r   )r6   r@   r	   r	   r
   Úremove_child§   s    zLayoutBox.remove_childc             C   sN   | j }x,| j| jgD ]}| |d¡ | |d¡ qW |  ¡  | jrJ|  ¡  d S )Ng    eÍÍAg        )r)   r   r   r;   r<   Úhard_constraintsr'   Úparent_constrain)r6   r>   Úir	   r	   r
   r1   ­   s    zLayoutBox.add_constraintsc             C   sT   | j }| j|jk| j|jk| j|jk| j|jkg}x|D ]}| j |dB ¡ q8W d S )Nr9   )r'   r   r   r   r   r)   r=   )r6   r'   Úhcr?   r	   r	   r
   rE   º   s    



zLayoutBox.parent_constrainc             C   s‚   | j | j| j k| j| j| j k| j| j| j d k| j| j| j d k| j | jk| j| j	kg}x|D ]}| j
 |dB ¡ qfW d S )Ng      à?r9   )r   r   r   r   r   r   r   r   r   r   r)   r=   )r6   rG   r?   r	   r	   r
   rD   Ã   s    

zLayoutBox.hard_constraintsc             C   s¦   | j }| jrd}nd}| j|k}x|D ]}| |dB ¡ q&W | jrHd}nd}| j|k}x|D ]}| |dB ¡ q\W | j|k| j|kg}x|D ]}| |dB ¡ qŒW d S )Ng        g      4@r9   iðI )r)   r0   r   r=   r/   r   r   r   )r6   r>   Zsuggestr?   rF   r	   r	   r
   Úsoft_constraintsÍ   s"    




zLayoutBox.soft_constraintsc             C   s   || _ |  ¡  dS )z8 replace the parent of this with the new parent
        N)r'   rE   )r6   r'   r	   r	   r
   Ú
set_parentã   s    zLayoutBox.set_parentr8   c             C   sF   | j |k| j|k| j|k| j|kg}x|D ]}| j ||B ¡ q*W d S )N)r   r   r   r   r)   r=   )r6   r   r   r   r   ÚstrengthrG   r?   r	   r	   r
   Úconstrain_geometryé   s    
zLayoutBox.constrain_geometryc             C   sN   | j |j k| j|jk| j|jk| j|jkg}x|D ]}| j ||B ¡ q2W dS )zJ
        Make the layoutbox have same position as other layoutbox
        N)r   r   r   r   r)   r=   )r6   ÚotherrJ   rG   r?   r	   r	   r
   Úconstrain_sameò   s    



zLayoutBox.constrain_samec             C   s&   | j | jj | k}| j ||B ¡ d S )N)r   r'   r)   r=   )r6   ÚmarginrJ   r?   r	   r	   r
   Úconstrain_left_marginý   s    zLayoutBox.constrain_left_marginc             C   s   | j  | j|¡ d S )N)r)   r<   r!   )r6   rN   r	   r	   r
   Úedit_left_margin_min  s    zLayoutBox.edit_left_margin_minc             C   s&   | j | jj | k}| j ||B ¡ d S )N)r   r'   r)   r=   )r6   rN   rJ   r?   r	   r	   r
   Úconstrain_right_margin  s    z LayoutBox.constrain_right_marginc             C   s   | j  | j|¡ d S )N)r)   r<   r"   )r6   rN   r	   r	   r
   Úedit_right_margin_min  s    zLayoutBox.edit_right_margin_minc             C   s&   | j | jj | k}| j ||B ¡ d S )N)r   r'   r)   r=   )r6   rN   rJ   r?   r	   r	   r
   Úconstrain_bottom_margin  s    z!LayoutBox.constrain_bottom_marginc             C   s   | j  | j|¡ d S )N)r)   r<   r#   )r6   rN   r	   r	   r
   Úedit_bottom_margin_min  s    z LayoutBox.edit_bottom_margin_minc             C   s&   | j | jj | k}| j ||B ¡ d S )N)r   r'   r)   r=   )r6   rN   rJ   r?   r	   r	   r
   Úconstrain_top_margin  s    zLayoutBox.constrain_top_marginc             C   s   | j  | j|¡ d S )N)r)   r<   r$   )r6   rN   r	   r	   r
   Úedit_top_margin_min  s    zLayoutBox.edit_top_margin_minc             C   s$   | j  ¡ | j ¡ | j ¡ | j ¡ fS )N)r   Úvaluer   r   r   )r6   r	   r	   r
   Úget_rect  s    zLayoutBox.get_rectc             C   s   | j  ¡  dS )zo
        Update *all* the variables that are part of the solver this LayoutBox
        is created with
        N)r)   ZupdateVariables)r6   r	   r	   r
   Úupdate_variables  s    zLayoutBox.update_variablesc             C   s@   | j }x&| jgD ]}| |¡s| ||¡ qW | | j|¡ dS )z—
        Set the height of the layout box.

        This is done as an editable variable so that the value can change
        due to resizing.
        N)r)   r   r:   r;   r<   )r6   r   rJ   r>   rF   r	   r	   r
   Úedit_height$  s
    
zLayoutBox.edit_heightc             C   s   | j |k}| j ||B ¡ dS )zr
        Constrain the height of the layout box.  height is
        either a float or a layoutbox.height.
        N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_height1  s    
zLayoutBox.constrain_heightc             C   s   | j |k}| j ||B ¡ d S )N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_height_min9  s    
zLayoutBox.constrain_height_minc             C   s@   | j }x&| jgD ]}| |¡s| ||¡ qW | | j|¡ d S )N)r)   r   r:   r;   r<   )r6   r   rJ   r>   rF   r	   r	   r
   Ú
edit_width=  s
    
zLayoutBox.edit_widthc             C   s   | j |k}| j ||B ¡ dS )zq
        Constrain the width of the layout box.  `width` is
        either a float or a layoutbox.width.
        N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_widthD  s    
zLayoutBox.constrain_widthc             C   s   | j |k}| j ||B ¡ d S )N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_width_minL  s    
zLayoutBox.constrain_width_minc             C   s   | j |k}| j ||B ¡ d S )N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_leftP  s    
zLayoutBox.constrain_leftc             C   s   | j |k}| j ||B ¡ d S )N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_bottomT  s    
zLayoutBox.constrain_bottomc             C   s   | j |k}| j ||B ¡ d S )N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_rightX  s    
zLayoutBox.constrain_rightc             C   s   | j |k}| j ||B ¡ d S )N)r   r)   r=   )r6   r   rJ   r?   r	   r	   r
   Úconstrain_top\  s    
zLayoutBox.constrain_topc             C   s    | j  d¡d }|dd… dkS )z]
        Helper to check if this layoutbox is the layoutbox of a
        subplotspec
        Ú.éÿÿÿÿNé   Zss)r(   Úsplit)r6   r(   r	   r	   r
   Ú_is_subplotspec_layoutbox`  s    z#LayoutBox._is_subplotspec_layoutboxc             C   s    | j  d¡d }|dd… dkS )zZ
        Helper to check if this layoutbox is the layoutbox of a
        gridspec
        rd   re   Né   Zgridspec)r(   rg   )r6   r(   r	   r	   r
   Ú_is_gridspec_layoutboxh  s    z LayoutBox._is_gridspec_layoutboxc             C   s2   | j r| g}ng }x| jD ]}|| ¡ 7 }qW |S )z‘
        Find children of this layout box that are subplots.  We want to line
        poss up, and this is an easy way to find them all.
        )r-   r2   Úfind_child_subplots)r6   Zsubplotsr@   r	   r	   r
   rk   p  s    zLayoutBox.find_child_subplotsc       ,         sæ  t | |||d}| ¡ }| ¡ \}}| j}	d‰d}
d}d‰|
ˆ }ˆ| }d}d}||||d    }|| }|jdk	r¦|| ‰tt|jƒƒ‰‡‡fdd„|jD ƒ}n
|g| }dg|g|d   }tj 	t 
tt||ƒƒ¡¡‰ ||||d    }|| }|jdk	r6|| ‰tt|jƒƒ‰‡‡fd	d„|jD ƒ}n
|g| }dg|g|d   }tj 	t 
tt||ƒƒ¡¡‰‡ ‡fd
d„t|ƒD ƒ}‡ ‡fdd„t|ƒD ƒ}‡‡fdd„t|ƒD ƒ}‡‡fdd„t|ƒD ƒ}t|j|ƒ\}}|| }|| }|| } || }!|jdk	rdt|j|ƒ\}"}#||" }$||" }%||# }&||# }'t||$ƒ}t| |&ƒ} t||%ƒ}t|!|'ƒ}!|!|  }(|| })| j}	| j|	j|	j|   k| j|	j|	j|  k| j|	j|( k| j|	j|) kg}*x|*D ]}+| j |+dB ¡ qÈW |S )a    Make a layout box from a subplotspec. The layout box is
        constrained to be a fraction of the width/height of the parent,
        and be a fraction of the parent width/height from the left/bottom
        of the parent.  Therefore the parent can move around and the
        layout for the subplot spec should move with it.

        The parent is *usually* the gridspec that made the subplotspec.??
        )r'   r(   r+   r,   g        g      ð?r   Nc                s   g | ]}ˆ | ˆ ‘qS r	   r	   )Ú.0Úr)Ú	netHeightÚtrr	   r
   ú
<listcomp>   s    z5LayoutBox.layout_from_subplotspec.<locals>.<listcomp>r   c                s   g | ]}ˆ | ˆ ‘qS r	   r	   )rl   rm   )ÚnetWidthro   r	   r
   rp   ¯  s    c                s   g | ]}ˆˆ d |   ‘qS )rf   r	   )rl   ÚrowNum)ÚcellHsr   r	   r
   rp   ¶  s    c                s    g | ]}ˆˆ d | d   ‘qS )rf   r   r	   )rl   rr   )rs   r   r	   r
   rp   ·  s    c                s   g | ]}ˆˆ d |   ‘qS )rf   r	   )rl   ÚcolNum)ÚcellWsr   r	   r
   rp   ¸  s    c                s    g | ]}ˆˆ d | d   ‘qS )rf   r   r	   )rl   rt   )ru   r   r	   r
   rp   ¹  s    r9   )r   Zget_gridspecZget_geometryr'   Z_row_height_ratiosÚfloatÚsumÚnpÚaddÚ
accumulateZravelÚlistÚzipZ_col_width_ratiosÚrangeÚdivmodZnum1Znum2ÚminÚmaxr   r   r   r   r)   r=   ),r6   Zsubspecr(   r+   r,   ÚlbZgsZnrowsZncolsr'   r   r   ZtotWidthZ	totHeightZhspaceZwspaceZcellHZsepHZcellHeightsZ
sepHeightsZcellWZsepWZ
cellWidthsZ	sepWidthsZfigTopsZ
figBottomsZfigLeftsZ	figRightsrr   rt   Z	figBottomZfigTopZfigLeftZfigRightZrowNum2ZcolNum2Z
figBottom2ZfigTop2ZfigLeft2Z	figRight2r   r   Zcsr?   r	   )rs   ru   r   rn   rq   r   ro   r
   Úlayout_from_subplotspec}  sx    









z!LayoutBox.layout_from_subplotspecc             C   s0   | j | j ¡ | j ¡ | j ¡ | j ¡ f}d| S )NzILayoutBox: %25s, (left: %1.3f) (bot: %1.3f) (right: %1.3f)  (top: %1.3f) )r(   r   rW   r   r   r   )r6   Úargsr	   r	   r
   Ú__repr__Ü  s    zLayoutBox.__repr__)Nr   FFNr   r   FFNN)r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r8   )r   NF)(Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   r3   r*   rC   r1   rE   rD   rH   rI   rK   rM   rO   rP   rQ   rR   rS   rT   rU   rV   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rh   rj   rk   r‚   r„   r	   r	   r	   r
   r   0   sP      
<0	

	















^r   r8   c             C   sL   xFt dt| ƒƒD ]4}| |d  j| | | jk}| | j ||B ¡ qW dS )zb
    Stack LayoutBox instances from left to right.
    `padding` is in figure-relative units.
    r   N)r}   Úlenr   r   r)   r=   )ÚboxesÚpaddingrJ   rF   r?   r	   r	   r
   Úhstackä  s    rŒ   c             C   sL   xFt dt| ƒƒD ]4}| |d  j| | | jk}| | j ||B ¡ qW dS )z7
    Stack LayoutBox instances from left to right.
    r   N)r}   r‰   r   r   r)   r=   )rŠ   r‹   rJ   rF   r?   r	   r	   r
   Úhpackï  s    r   c             C   sL   xFt dt| ƒƒD ]4}| |d  j| | | jk}| | j ||B ¡ qW dS )z6
    Stack LayoutBox instances from top to bottom
    r   N)r}   r‰   r   r   r)   r=   )rŠ   r‹   rJ   rF   r?   r	   r	   r
   Úvstackù  s    rŽ   c             C   sL   xFt dt| ƒƒD ]4}| |d  j| | | jk}| | j ||B ¡ qW dS )z6
    Stack LayoutBox instances from top to bottom
    r   N)r}   r‰   r   r   r)   r=   )rŠ   r‹   rJ   rF   r?   r	   r	   r
   Úvpack  s    r   Úmediumc             C   sr   |dkrt  t| ƒ¡}xVtdt| ƒƒD ]D}| |d  j| | j||d   ||  k}| | j ||B ¡ q&W dS )z6
    Stack LayoutBox instances from top to bottom
    Nr   )rx   Úonesr‰   r}   r   r)   r=   )rŠ   Úheight_ratiosrJ   rF   r?   r	   r	   r
   Úmatch_heights  s     r“   c             C   sr   |dkrt  t| ƒ¡}xVtdt| ƒƒD ]D}| |d  j| | j||d   ||  k}| | j ||B ¡ q&W dS )z6
    Stack LayoutBox instances from top to bottom
    Nr   )rx   r‘   r‰   r}   r   r)   r=   )rŠ   Úwidth_ratiosrJ   rF   r?   r	   r	   r
   Úmatch_widths  s     r•   c             C   s   t | |d t| |d d S )N)r‹   )r’   )rŽ   r“   )rŠ   r‹   r’   r	   r	   r
   Úvstackeq'  s    r–   c             C   s   t | |d t| |d d S )N)r‹   )r”   )rŒ   r•   )rŠ   r‹   r”   r	   r	   r
   Úhstackeq,  s    r—   c             C   sJ   g }x@| dd … D ]0}t | d |ƒt ||ƒk}| d j ||B ¡ qW d S )Nr   r   )Úgetattrr)   r=   )rŠ   ÚattrrJ   ZconsÚboxr	   r	   r
   Úalign1  s    r›   r   c             C   s‚   | d }|}xt |ƒD ]
}|j}qW xX| dd … D ]H}|}xt |ƒD ]
}|j}qDW |j|j |j|j k}|j |dB ¡ q2W d S )Nr   r   r8   )r}   r'   r   r)   r=   )rŠ   ÚlevelsÚbox0Útop0Únrš   Útopbr?   r	   r	   r
   Úmatch_top_margins8  s    

r¡   c             C   s‚   | d }|}xt |ƒD ]
}|j}qW xX| dd … D ]H}|}xt |ƒD ]
}|j}qDW |j|j |j|j k}|j |dB ¡ q2W d S )Nr   r   r8   )r}   r'   r   r)   r=   )rŠ   rœ   r   rž   rŸ   rš   r    r?   r	   r	   r
   Úmatch_bottom_marginsE  s    

r¢   c             C   s‚   | d }|}xt |ƒD ]
}|j}qW xX| dd … D ]H}|}xt |ƒD ]
}|j}qDW |j|j |j|j k}|j |dB ¡ q2W d S )Nr   r   r8   )r}   r'   r   r)   r=   )rŠ   rœ   r   rž   rŸ   rš   r    r?   r	   r	   r
   Úmatch_left_marginsR  s    

r£   c             C   s‚   | d }|}xt |ƒD ]
}|j}qW xX| dd … D ]H}|}xt |ƒD ]
}|j}qDW |j|j |j|j k}|j |dB ¡ q2W d S )Nr   r   r8   )r}   r'   r   r)   r=   )rŠ   rœ   r   rž   rŸ   rš   r    r?   r	   r	   r
   Úmatch_right_margins_  s    

r¤   c             C   s   t | |d t| |d d S )N)rœ   )r£   r¤   )rŠ   rœ   r	   r	   r
   Úmatch_width_marginsl  s    r¥   c             C   s   t | |d t| |d d S )N)rœ   )r¡   r¢   )rŠ   rœ   r	   r	   r
   Úmatch_height_marginsq  s    r¦   c             C   s   t | |d t| |d d S )N)rœ   )r¥   r¦   )rŠ   rœ   r	   r	   r
   Úmatch_marginsv  s    r§   c               C   s   dt tƒ S )zA
    Generate a short sequential id for layoutbox objects...
    z%06d)ÚnextÚ_layoutboxobjnumr	   r	   r	   r
   Úseq_id~  s    rª   c             C   s$   t | ƒ x| jD ]}t|ƒ qW dS )z-
    Print the children of the layoutbox
    N)Úprintr2   Úprint_children)r   r@   r	   r	   r
   r¬   ˆ  s    r¬   c             C   s4   | dk	r0| j dkr&| j ¡  t| ƒ n
t| j ƒ dS )z]
    Make all elements in this tree none...  This signals not to do any more
    layout.
    N)r'   r)   ÚresetÚnonechildrenÚnonetree)r   r	   r	   r
   r¯   ‘  s
    


r¯   c             C   s(   x| j D ]}t|ƒ qW d | j_d } d S )N)r2   r®   r+   Z
_layoutbox)r   r@   r	   r	   r
   r®   Ÿ  s    r®   c             C   s:   | j dkr,tdƒ tdƒ t| ƒ tdƒ n
t| j ƒ dS )z'
    Print the tree of layoutboxes
    NzLayoutBox Tree
z==============
Ú
)r'   r«   r¬   Ú
print_tree)r   r	   r	   r
   r±   ¦  s    

r±   Tc             C   sˆ  ddl }ddlm} t| |jjƒrb|  ddddg¡}| ddddg¡ | d¡ |  	| j
 ¡ ¡ n| }ddlm} |jd  ¡ d }|r’td	|ƒ xð|jD ]æ}	|	 ¡ }
|r²t|	ƒ | |j|	j ¡ |	j ¡ f|	j ¡ |	j ¡ d
d|| d¡ |dkrl|	j d¡d }|d dkr@|j|	j ¡ |	j ¡ |d| || d n,|j|	j ¡ |	j ¡ |ddd| || d t||	|d |d qšW dS )z1
    Simple plotting to show where boxes are
    r   Ng        g      ð?gffffffæ?g333333Ó?zaxes.prop_cycleÚcolorzLevel:Znonegš™™™™™é?)ZfcZalphaZecrd   re   rf   é   )Úsizer²   r   r   )ZhaZvar´   r²   r   )ÚlevelÚprintit) Ú
matplotlibZmatplotlib.pyplotZpyplotÚ
isinstanceZfigureZFigureZadd_axesZset_facecolorZ	set_alphaZdrawr   r   Zmatplotlib.patchesÚpatchesZrcParamsZby_keyr«   r2   rX   Z	add_patchZ	Rectangler   rW   r   r   r   r(   rg   Útextr   r   Úplot_children)r   rš   rµ   r¶   r·   ZpltZaxr¹   Zcolorsr@   Zrectr(   r	   r	   r
   r»   ´  sB    



r»   )r   r8   )r   r8   )r   r8   )r   r8   )Nr   )Nr   )r   N)r   N)r8   )r   )r   )r   )r   )r   )r   )r   )r   T)'rˆ   Ú	itertoolsZ
kiwisolverr%   ZloggingZnumpyrx   Úwarningsr·   Z	getLoggerr…   r   r   Úobjectr   rŒ   r   rŽ   r   r“   r•   r–   r—   r›   r¡   r¢   r£   r¤   r¥   r¦   r§   Úcountr©   rª   r¬   r¯   r®   r±   r»   r	   r	   r	   r
   Ú<module>   sF   
   7



















	