� �)�Uc@s�dZddljZddljZddljZ ddl Z ddlm Z m Z mZmZmZddlmZddlmZmZddlmZddlmZddljZddlmZdd lmZeZ d �Zd d �Z!d d�Z"dej#fd��YZ$de$fd��YZ%de%fd��YZ&de%fd��YZ'de$fd��YZ(de$fd��YZ)de$fd��YZ*de$fd��YZ+de+fd ��YZ,d!e$fd"��YZ-dd#lm.Z.d$ej#e.fd%��YZ/d&e0fd'��YZ1d(e1fd)��YZ2d*e1fd+��YZ3e4d,kr�e5j6d-�Z7e7j8�e5j9d.�Z:e;�Z<e j=d/�j>d0d0�d1Z?e-e?d2d3d4dd5de<�ZAe:jBeA�eAjCdJ�e-e?d2d3d4dd5de<�ZDe/eDdKd8dLd:d;d<d=d>eEd?d@dAe;dBdCdDdE�dFddGe;dHdI��ZFe:jBeF�e5jG�e5jH�ndS(Ms� The OffsetBox is a simple container artist. The child artist are meant to be drawn at a relative position to its parent. The [VH]Packer, DrawingArea and TextArea are derived from the OffsetBox. The [VH]Packer automatically adjust the relative postisions of their children, which should be instances of the OffsetBox. This is used to align similar artists together, e.g., in legend. The DrawingArea can contain any Artist as a child. The DrawingArea has a fixed width and height. The position of children relative to the parent is fixed. The TextArea is contains a single Text instance. The width and height of the TextArea instance is the width and height of the its child text. i����N(tBboxtBboxBasetTransformedBboxtIdentityTransformtBboxTransformFrom(tFontProperties(tFancyBboxPatchtFancyArrowPatch(trcParams(t docstring(t BboxImage(t bbox_artistcOstrt||�ndS(N(tDEBUGt mbbox_artist(targstkwargs((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR (stfixedc Cs�t|�\}}|dkrtjjdgg|D]}||^q4�}|d }|dkru|d|}n||fS|dkr�|t|�t|�d}tjjdgg|D]}||^q��}|d }||fS|dkr�t|�} |dkr(| |t|�}nt|�t|�| }tj gt t|��D]} | || ^q[�}||fSt d|f��dS( s� Geiven a list of (width, xdescent) of each boxes, calculate the total width and the x-offset positions of each items according to *mode*. xdescent is analagous to the usual descent, but along the x-direction. xdescent values are currently ignored. *wd_list* : list of (width, xdescent) of boxes to be packed. *sep* : spacing between boxes *total* : Intended total length. None if not used. *mode* : packing mode. 'fixed', 'expand', or 'equal'. Rii����texpandg�?tequalsUnknown mode : %sN( tziptnptaddt accumulatetNonetsumtlentmaxtfloattarraytranget ValueError( twd_listttotaltseptmodetw_listtd_listtwtoffsets_toffsetstmaxhti((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt_get_packed_offsets1s(  0    0     6 tbaselinecCs�|d kr4tg|D]\}}|^q�}n|dkr�tg|D]\}}||^qJ�}tg|D]\}}|^qs�}||}g|D]\}}d^q�}n�|d kr�d}g|D]\}}|^q�}n�|d kr*d}g|D]\}}|||^q}nS|dkrjd}g|D]\}}||d|^qC}ntd |f��|||fS( s* Geiven a list of (height, descent) of each boxes, align the boxes with *align* and calculate the y-offsets of each boxes. total width and the offset positions of each items according to *mode*. xdescent is analagous to the usual descent, but along the x-direction. xdescent values are currently ignored. *hd_list* : list of (width, xdescent) of boxes to be aligned. *sep* : spacing between boxes *height* : Intended total length. None if not used. *align* : align mode. 'baseline', 'top', 'bottom', or 'center'. R+gtleftttoptrighttbottomtcenterg�?sUnknown Align mode : %sN(R,stop(R.R/(RRR(thd_listtheighttalignthtdtheight_descenttdescentR'((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt_get_aligned_offsets`s$ ( )% " " * .t OffsetBoxcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z d �Z d �Zd �ZRS(s� The OffsetBox is a simple container artist. The child artist are meant to be drawn at a relative position to its parent. cOs/tt|�j||�g|_d|_dS(Ni(ii(tsuperR9t__init__t _childrent_offset(tselfRR((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�s cCs;tjj||�x!|j�D]}|j|�q WdS(s^ Set the figure accepts a class:`~matplotlib.figure.Figure` instance N(tmartisttArtistt set_figuret get_children(R>tfigtc((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRA�scCsFx9|j�D]+}|j|�\}}|r ||fSq WtifS(N(RBtcontainstFalse(R>t mouseeventRDtatb((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRE�s cCs ||_dS(sT Set the offset accepts x, y, tuple, or a callable object. N(R=(R>txy((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt set_offset�scCs3t|j�r(|j|||||�S|jSdS(sC Get the offset accepts extent of the box N(tcallableR=(R>twidthR2txdescenttydescenttrenderer((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt get_offset�scCs ||_dS(s6 Set the width accepts float N(RM(R>RM((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt set_width�scCs ||_dS(s7 Set the height accepts float N(R2(R>R2((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt set_height�scCs&g|jD]}|j�r |^q S(s? Return a list of visible artists it contains. (R<t get_visible(R>RD((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_visible_children�scCs|jS(s7 Return a list of artists it contains. (R<(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRB�scCstd��dS(Nt(t Exception(R>RP((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_extent_offsets�scCs.|j|�\}}}}}||||fS(s@ Return with, height, xdescent, ydescent of box (RX(R>RPR%R4txdtydR'((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt get_extent�sc Cs`|j|�\}}}}}|j|||||�\}}tjj||||||�S(s8 get the bounding box in display space. (RXRQt mtransformsRt from_bounds( R>RPR%R4RYRZR'tpxtpy((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_window_extent�s!c Cs�|j|�\}}}}}|j|||||�\}}xQt|j�|�D]:\} \} } | j|| || f�| j|�qUWt||dtdtdd��dS(sm Update the location of children if necessary and draw them to the given *renderer*. tfilltpropstpadgN( RXRQRRURKtdrawR RFtdict( R>RPRMR2RNROR'R^R_RDtoxtoy((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRd�s !((t__name__t __module__t__doc__R;RARERKRQRRRSRURBRXR[R`Rd(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR9�s          t PackerBasecBs&eZdddddddd�ZRS(cCsVtt|�j�||_||_||_||_||_||_||_ dS(s� *pad* : boundary pad *sep* : spacing between items *width*, *height* : width and height of the container box. calculated if None. *align* : alignment of boxes. Can be one of 'top', 'bottom', 'left', 'right', 'center' and 'baseline' *mode* : packing mode .. note:: *pad* and *sep* need to given in points and will be scale with the renderer dpi, while *width* and *hight* need to be in pixels. N( R:RkR;R2RMR!RcR"R3R<(R>RcR!RMR2R3R"tchildren((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�s      N(RhRiRR;(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRk�s tVPackercBs5eZdZdddddddd�Zd�ZRS(s� The VPacker has its children packed vertically. It automatically adjust the relative postisions of children in the drawing time. R+RcCs,tt|�j|||||||�dS(s� *pad* : boundary pad *sep* : spacing between items *width*, *height* : width and height of the container box. calculated if None. *align* : alignment of boxes *mode* : packing mode .. note:: *pad* and *sep* need to given in points and will be scale with the renderer dpi, while *width* and *hight* need to be in pixels. N(R:RmR;(R>RcR!RMR2R3R"Rl((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;scCs�|jd�}|j|}|j|}|jdk r�xH|j�D]7}t|t�rE|jdkrE|j |j�qEqEWng|j�D]}|j |�^q�}g|D](\}}} } ||| || f^q�}g|D]\}}} } || f^q�} t | |j|j �\} } }g|D]\}}} } || f^q3}t ||j||j�\}}|g|D]\}}} } | ^q�}||d}||}||}| d||d|| |||t||�fS(sN update offset of childrens and return the extents of the box g�?RiiN(tpoints_to_pixelsRcR!RMRRUt isinstanceRkR"RRR[R8R3R*R2R(R>RPtdpicorRcR!RDtwhd_listR%R4RYRZRRMRNtxoffsetst pack_listR2t yoffsets_tyoffsetsRO((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRX.s.  (5++ )  N(RhRiRjRR;RX(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRms   tHPackercBs5eZdZdddddddd�Zd�ZRS(s� The HPacker has its children packed horizontally. It automatically adjust the relative postisions of children in the drawing time. R+RcCs,tt|�j|||||||�dS(s� *pad* : boundary pad *sep* : spacing between items *width*, *height* : width and height of the container box. calculated if None. *align* : alignment of boxes *mode* : packing mode .. note:: *pad* and *sep* need to given in points and will be scale with the renderer dpi, while *width* and *hight* need to be in pixels. N(R:RvR;(R>RcR!RMR2R3R"Rl((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;[scCs|jd�}|j|}|j|}g|j�D]}|j|�^q6}|srd|d|||gfS|jdkr�tg|D]\}}} } || ^q��} tg|D]\}}} } | ^q��} | | } n|jd|} g|D]\}}} } || f^q}t||j|j �\} } }g|D]\}}} } || f^qL}t ||j ||j �\}}|g|D]\}}} } | ^q�}|dd}||}|d|| d|||| |t ||�fS(sN update offset of childrens and return the extents of the box g�?iiN(RnRcR!RUR[R2RRR8R3R*RMR"R(R>RPRpRcR!RDRqR%R4RYRZR6ROR2R1RuRsRMt xoffsets_RrRN((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRXos0  (/+ ++ ) N(RhRiRjRR;RX(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRvVs   t DrawingAreacBsheZdZdded�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z RS( s� The DrawingArea can contain any Artist as a child. The DrawingArea has a fixed width and height. The position of children relative to the parent is fixed. gcCsytt|�j�||_||_||_||_tj�|_ |j j �|j j dd�tj�|_ dS(s� *width*, *height* : width and height of the container box. *xdescent*, *ydescent* : descent of the box in x- and y-direction. iN( R:RxR;RMR2RNROR\tAffine2Dtoffset_transformtcleart translatet dpi_transform(R>RMR2RNROtclip((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�s     cCs|j|jS(sf Return the :class:`~matplotlib.transforms.Transform` applied to the children (R}Rz(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt get_transform�scCsdS(s+ set_transform is ignored. N((R>tt((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt set_transform�scCs5||_|jj�|jj|d|d�dS(sj set offset of the container. Accept : tuple of x,y cooridnate in disokay units. iiN(R=RzR{R|(R>RJ((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRK�s  cCs|jS(s1 return offset of the container. (R=(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRQ�scCsN|j|�\}}}}|j�\}}tjj||||||�S(s8 get the bounding box in display space. (R[RQR\RR](R>RPR%R4RYRZRfRg((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR`�scCs;|jd�}|j||j||j||j|fS(s@ Return with, height, xdescent, ydescent of box g�?(RnRMR2RNRO(R>RPtdpi_cor((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR[�scCs'|jj|�|j|j��dS(s?Add any :class:`~matplotlib.artist.Artist` to the container boxN(R<tappendR�R(R>RH((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt add_artist�sc Csv|jd�}|jj�|jj||�x|jD]}|j|�q9Wt||dtdtdd��dS(s# Draw the children g�?RaRbRcgN( RnR}R{tscaleR<RdR RFRe(R>RPR�RD((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRd�s  ( RhRiRjtTrueR;RR�RKRQR`R[R�Rd(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRx�s    tTextAreacBs�eZdZdded�Zd�Zd�Zd�Zd�Z d�Z d�Z d�Z d �Z d �Zd �Zd �Zd �ZRS(s� The TextArea is contains a single Text instance. The text is placed at (0,0) with baseline+left alignment. The width and height of the TextArea instance is the width and height of the its child text. cCs�|dkri}n|jd�s1d|d<ntjdd||�|_tj|�|jg|_tj �|_ |j j �|j j dd�tj �|_ |jj|j |j �||_||_dS(s� *s* : a string to be displayed. *textprops* : property dictionary for the text *multilinebaseline* : If True, baseline for multiline text is adjusted so that it is (approximatedly) center-aligned with singleline text. *minimumdescent* : If True, the box has a minimum descent of "p". tvaR+iN(Rthas_keytmtexttTextt_textR9R;R<R\RyRzR{R|t_baseline_transformR�t_multilinebaselinet_minimumdescent(R>tst textpropstmultilinebaselinetminimumdescent((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR; s      cCs|jj|�dS(sset textN(R�tset_text(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�.scCs |jj�S(sget text(R�tget_text(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�2scCs ||_dS(s� Set multilinebaseline . If True, baseline for multiline text is adjusted so that it is (approximatedly) center-aligned with singleline text. N(R�(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytset_multilinebaseline6scCs|jS(s) get multilinebaseline . (R�(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_multilinebaselineAscCs ||_dS(s� Set minimumdescent . If True, extent of the single line text is adjusted so that it has minimum descent of "p" N(R�(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytset_minimumdescentHscCs|jS(s% get minimumdescent. (R�(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_minimumdescentRscCsdS(s+ set_transform is ignored. N((R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�YscCs5||_|jj�|jj|d|d�dS(sj set offset of the container. Accept : tuple of x,y cooridnate in disokay units. iiN(R=RzR{R|(R>RJ((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRK`s  cCs|jS(s1 return offset of the container. (R=(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRQlscCsN|j|�\}}}}|j�\}}tjj||||||�S(s8 get the bounding box in display space. (R[RQR\RR](R>RPR%R4RYRZRfRg((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR`sscCsX|jj|jj�\}}|jd|jjdt�\}}}|jj|�\}}|j|j} } |dd} |j| |jjd|�\}} } | }|jj �t |�dkr |j r d| d||}|jj d||�|}n?t ||| |�}|j�r>t ||�}n||} | | d|fS(Ntlptismathi����iig�?g(R�t is_math_texttget_text_width_height_descentt_fontpropertiesRFt _get_layoutRMR2R�R{RR�R|RR�(R>RPt clean_lineR�t_th_td_tbboxtinfoR%R4tlinethhtddR5td_newth_d((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR[|s&!!    c Cs6|jj|�t||dtdtdd��dS(s# Draw the children RaRbRcgN(R�RdR RFRe(R>RP((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRd�sN(RhRiRjRR�R;R�R�R�R�R�R�R�RKRQR`R[Rd(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�s  !       %tAuxTransformBoxcBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z RS( sX Offset Box with the aux_transform . Its children will be transformed with the aux_transform first then will be offseted. The absolute coordinate of the aux_transform is meaning as it will be automaticcaly adjust so that the left-lower corner of the bounding box of children will be set to (0,0) before the offset trnasform. It is similar to drawing area, except that the extent of the box is not predetemined but calculated from the window extent of its children. Furthermore, the extent of the children will be calculated in the transformed coordinate. cCse||_tj|�tj�|_|jj�|jjdd�tj�|_|jj�dS(Ni( t aux_transformR9R;R\RyRzR{R|tref_offset_transform(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�s   cCs'|jj|�|j|j��dS(s?Add any :class:`~matplotlib.artist.Artist` to the container boxN(R<R�R�R(R>RH((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR��scCs|j|j|jS(sf Return the :class:`~matplotlib.transforms.Transform` applied to the children (R�R�Rz(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�s cCsdS(s+ set_transform is ignored. N((R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR��scCs5||_|jj�|jj|d|d�dS(sj set offset of the container. Accept : tuple of x,y cooridnate in disokay units. iiN(R=RzR{R|(R>RJ((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRK�s  cCs|jS(s1 return offset of the container. (R=(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRQ�scCsN|j|�\}}}}|j�\}}tjj||||||�S(s8 get the bounding box in display space. (R[RQR\RR](R>RPR%R4RYRZRfRg((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR`�scCs�|jj�}|jj�|jj�g|jD]}|j|�^q3}tjj|�}|jj |j |j �|jj |�}|jj |�|j|jddfS(Ng(Rzt to_valuesR�R{R<R`R\RtunionR|tx0ty0tmatrix_from_valuest set_matrixRMR2(R>RPt_offRDtbboxestubtmtx((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR[�s  %c CsGx|jD]}|j|�q Wt||dtdtdd��dS(s# Draw the children RaRbRcgN(R<RdR RFRe(R>RPRD((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRds( RhRiRjR;R�RR�RKRQR`R[Rd(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR��s      tAnchoredOffsetboxcBs�eZdZdZddddeddd�Zd�Zd�Zd�Z d�Z d �Z dd �Z d �Z dd �Zdd �Zd�Zd�ZRS(s6 An offset box placed according to the legend location loc. AnchoredOffsetbox has a single child. When multiple children is needed, use other OffsetBox class to enlose them. By default, the offset box is anchored against its parent axes. You may explicitly specify the bbox_to_anchor. ig�������?g�?c Ks"tt|�j| �|j||�|j|�||_||_||_|dkrst dt d�|_ nMt |t �r�t |�|_ d|kr�|j jt d�q�n ||_ tdddddddd d d d |j j�d t�|_|jjddd�||_dS(s� loc is a string or an integer specifying the legend location. The valid location codes are:: 'upper right' : 1, 'upper left' : 2, 'lower left' : 3, 'lower right' : 4, 'right' : 5, 'center left' : 6, 'center right' : 7, 'lower center' : 8, 'upper center' : 9, 'center' : 10, pad : pad around the child for drawing a frame. given in fraction of fontsize. borderpad : pad between offsetbox frame and the bbox_to_anchor, child : OffsetBox instance that will be anchored. prop : font property. This is only used as a reference for paddings. frameon : draw a frame box if True. bbox_to_anchor : bbox to anchor. Use self.axes.bbox if None. bbox_transform : with which the bbox_to_anchor will be transformed. tsizeslegend.fontsizeRJgRMg�?R2t facecolorR%t edgecolortktmutation_scaletsnaptsquareRciN(gg(R:R�R;tset_bbox_to_anchort set_childtloct borderpadRcRRRtpropRoRetset_sizeRtget_size_in_pointsR�tpatcht set_boxstylet _drawFrame( R>R�RcR�tchildR�tframeontbbox_to_anchortbbox_transformR((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;(s(&         cCs ||_dS(sset the child to be anchoredN(t_child(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�lscCs|jS(sreturn the child(R�(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt get_childpscCs |jgS(sreturn the list of children(R�(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRBtscCsn|j�j|�\}}}}|j|jj��}|j|}|d||d|||||fS(sq return the extent of the artist. The extent of the child added with the pad is returned i(R�R[RnR�R�Rc(R>RPR%R4RYRZtfontsizeRc((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR[ys! cCsI|jdkr|jjS|j}|dkr5|jSt|j|�SdS(sB return the bbox that the legend will be anchored N(t_bbox_to_anchorRtaxesR�t_bbox_to_anchor_transformR(R>t transform((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_bbox_to_anchor�s    cCs�|dkst|t�r'||_nuyt|�}Wn'tk r`tdt|���nX|dkr�|d|dddg}ntj |�|_||_ dS(sF set the bbox that the child will be anchored. *bbox* can be a Bbox instance, a list of [left, bottom, width, height], or a list of [left, bottom] where the width and height will be assumed to be zero. The bbox will be transformed to display coordinate by the given transform. sInvalid argument for bbox : %siiiN( RRoRR�Rt TypeErrorRtstrRR]R�(R>R�R�tl((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR��s    cCsg|j|�|j|�\}}}}|j|||||�\}}tj||||||�S(s8 get the bounding box in display space. (t_update_offset_funcR[RQRR](R>RPR%R4RYRZRfRg((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR`�s !cCsG|dkr'|j|jj��}n||d�}|j|�dS(ss Update the offset func which depends on the dpi of the renderer (because of the padding). c Ssdtjdd||�}|j|}|j�} |j|j|| |�\} } | || |fS(Ni(RR]R�R�t_get_anchored_bboxR�( R%R4RYRZRPR�R>R�R�R�R�R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR=�s   N(RRnR�R�RK(R>RPR�R=((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR��s  cCsB|jj|j|j|j|j�|r>|jj|�ndS(N(R�t set_boundsR�R�RMR2tset_mutation_scale(R>R�R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt update_frame�sc Cs�|j�sdS|j|jj��}|j||�|jrs|j|�}|j||�|jj |�n|j |�\}}}}|j |||||�\}} |j �j || f�|j �j |�dS(sdraw the artistN(RTRnR�R�R�R�R`R�R�RdR[RQR�RK( R>RPR�R�RMR2RNROR^R_((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRd�s  !c Cs�|tdd�kst�td�\ }}}}} } } } } }}i d|6d|6d|6d| 6d| 6d| 6d| 6d | 6d |6d |6}||}|j| �}|j|d |�}|j|jfS( s{ return the position of the bbox anchored at the parentbbox with the loc code, with the borderpad. ii tNEtNWtSWtSEtEtWtStNtCt container(RtAssertionErrortpaddedtanchoredR�R�(R>R�R�t parentbboxR�tBESTtURtULtLLtLRtRtCLtCRtLCtUCR�t anchor_coefsRDR�t anchored_box((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR��s -   N(RhRiRjtzorderRR�R;R�R�RBR[R�R�R`R�R�RdR�(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�s"  @        t AnchoredTextcBs eZdZdddd�ZRS(s% AnchoredOffsetbox with Text g�������?g�?c Kset|d|dt�|_|jjj�}tt|�j|d|d|d|jd||�dS(sC *s* : string *loc* : location code *prop* : font property *pad* : pad between the text and the frame as fraction of the font size. *borderpad* : pad between the frame and the axes (or bbox_to_anchor). other keyword parameters of AnchoredOffsetbox are also allowed. R�R�RcR�R�R�N(R�RFttxtR�tget_fontpropertiesR:R�R;(R>R�R�RcR�R�Rtfp((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;s  ! N(RhRiRjRR;(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR� st OffsetImagec Bs}eZdd d d d ddeed� Zd�Zd�Zd�Zd�Z d�Z d�Z d �Z d �Z d �ZRS( ig@c Ks�| |_td|jd|d|d|d|d|d|d| | �|_|jg|_|j|�|j|�tj|�dS( NR�tcmaptnormt interpolationtorigint filternormt filterradtresample( t_dpi_corR R`timageR<tset_zoomtset_dataR9R;( R>tarrtzoomR�R�RRRRRR�R((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;%s    cCs)tj|�|_|jj|j�dS(N(Rtasarrayt_dataRR(R>R ((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRGscCs|jS(N(R (R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_dataKscCs ||_dS(N(t_zoom(R>R ((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRNscCs|jS(N(R(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_zoomQscCs|jS(s1 return offset of the container. (R=(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRQescCs |jgS(N(R(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRBkscCsN|j|�\}}}}|j�\}}tjj||||||�S(s8 get the bounding box in display space. (R[RQR\RR](R>RPR%R4RYRZRfRg((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR`nsc Csq|jr|jd�}nd}|j�}|j�}|jd \}}||||}}||ddfS(Ng�?ii(RRnRR tshape( R>RPR�R tdatatnytnxR%R4((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR[ws   cCs|jj|�dS(s# Draw the children N(RRd(R>RP((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRd�sN(RhRiRRFR�R;RR RRRQRBR`R[Rd(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�$s$        (t_AnnotationBasetAnnotationBboxc Bs�eZdZdZd�Zejdddeddddddd� �Z d�Z d�Z d �Z dd �Z dd �Zd �Zd �Zd�ZRS(sD Annotation-like class, but with offsetbox instead of Text. icCsd|jd|jdfS(NsAnnotationBbox(%g,%g)ii(RJ(R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt__str__�sRg�������?g�?c Ks/||_| |_|j| �| dk r^|jjdd�|_tdd|j�|_nd|_d|_tj ||d|d|d|d|�t j j || �| |_ t d dd d d d ddddd|jj�dt�|_|jjdd|�| r"|jj| �n||_dS(so *offsetbox* : OffsetBox instance *xycoords* : same as Annotation but can be a tuple of two strings which are interpreted as x and y coordinates. *boxcoords* : similar to textcoords as Annotation but can be a tuple of two strings which are interpreted as x and y coordinates. *box_alignment* : a tuple of two floats for a vertical and horizontal alignment of the offset box w.r.t. the *boxcoords*. The lower-left corner is (0.0) and upper-right corner is (1.1). other parameters are identical to that of Annotation. trelposg�?iitxytexttxycoordst textcoordstannotation_clipRJgRMg�?R2R�R%R�R�R�R�R�RcN(g�?g�?(ii(ii(gg(t offsetboxt arrowpropst set_fontsizeRtpopt _arrow_relposRt arrow_patchRR;R?R@t_box_alignmentRR�R�R�R�R�tsetR�(R>RRJtxyboxRt boxcoordsR�RcRt box_alignmentt bboxpropsRR�R((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�s0             cCs"|jj|�\}}||fS(N(RRE(R>teventR�ttinfo((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRE�scCs2|j|jg}|jr.|j|j�n|S(N(RR�R!R�(R>Rl((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRB�s cCsI|jdk r"|jj|�n|jj|�tjj||�dS(N(R!RRARR?R@(R>RC((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRA�scCs/|dkrtd}ntd|�|_dS(s( set fontsize in points slegend.fontsizeR�N(RRRR�(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�s  cCs |jj�S(s+ return fontsize in points (R�R�(R>R�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt get_fontsizescCsd|j|�}|j||�|j|j��}|jj|�|jr`|jj|�ndS(s?Update the pixel positions of the annotated point and the text.N(t_get_position_xyt_update_position_xyboxRnR*R�R�R!(R>RPtxy_pixelR�((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytupdate_positionss  cCs1|j\}}t|jt�r||j\}}|j||||�\}}|j||||�\} } || } } n!|j||||j�\} } |jj|�\} }}}|j\}}|jj| || || |||f�|jj |�}|j j |j |j |j|j�|\}}||}}|jr-||}}|jj�}|j}|j |j|d} |j |j|d} |jj| | f||f�|jj�}|jd|�}|j|�}|jj|�|jd|j �}|jj|�ndS(sFUpdate the pixel positions of the annotation text and the arrow patch.iiR�tpatchAN(RRoRttuplet_get_xyRR[R"RKR`R�R�R�R�RMR2RtcopyR R!t set_positionsR�R�RRnR�t set_patchA(R>RPR-txtytxcoordtycoordtx1ty1tx2ty2tox0toy0R%R4RYRZt_fwt_fhR�tox1toy1R�R�R5RtfsR�R/((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR,s8!.     cCs�|dk r||_n|j�s(dS|j|�}|j||�sMdS|j|�|jdk r�|jjdkr�|jdk r�|j|j_n|jj|�n|j r�|j j|�n|j j|�dS(sN Draw the :class:`Annotation` object to the given *renderer*. N( Rt _rendererRTR+t _check_xyR.R!tfigureRdR�R�R(R>RPR-((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRdMs    ! N(g�?g�?(RhRiRjR�RR tdedent_interpdRR�R;RERBRARR*R.R,Rd(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR�s* 8    ;t DraggableBasecBskeZdZed�Zd�Zd�Zd�Zd�Zd�Z d�Z d�Z d �Z d �Z RS( s, helper code for a draggable artist (legend, offsetbox) The derived class must override following two method. def saveoffset(self): pass def update_offset(self, dx, dy): pass *saveoffset* is called when the object is picked for dragging and it is meant to save reference position of the artist. *update_offset* is called during the dragging. dx and dy is the pixel offset from the point where the mouse drag started. Optionally you may override following two methods. def artist_picker(self, artist, evt): return self.ref_artist.contains(evt) def finalize_offset(self): pass *artist_picker* is a picker method that will be used. *finalize_offset* is called when the mouse is released. In current implementaion of DraggableLegend and DraggableAnnotation, *update_offset* places the artists simply in display coordinates. And *finalize_offset* recalculate their position in the normalized axes coordinate and set a relavant attribute. cCs�||_t|_||_|jjj|_|jjd|j�}|jjd|j�}|j |j �||g|_ dS(Nt pick_eventtbutton_release_event( t ref_artistRFt got_artistt _use_blitRFtcanvast mpl_connectton_pickt on_releaset set_pickert artist_pickertcids(R>RKtuse_blittc2tc3((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�s   cCsM|jrI|j|j}|j|j}|j||�|jj�ndS(N(RLR5tmouse_xR6tmouse_yt update_offsetRNRd(R>tevttdxtdy((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt on_motion�s  cCs�|jr�|j|j}|j|j}|j||�|jj|j�|j j |j j j �|jj |j j j�ndS(N(RLR5RXR6RYRZRNtrestore_regiont backgroundRKRdRFt_cachedRenderertblitR�(R>R[R\R]((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyton_motion_blit�s cCs�|j|jkr�|jj|_|jj|_t|_|j r�|jj t�|j j �|j j |jjj�|_|jj |jjj�|j j|jjj�|j jd|j�|_n|j jd|j�|_|j�ndS(Ntmotion_notify_event(tartistRKRGR5RXR6RYR�RLRMt set_animatedRNRdtcopy_from_bboxRFR�R`RaRbRORct_c1R^t save_offset(R>R[((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRP�s   cCsR|jrN|j�t|_|jj|j�|jrN|jjt�qNndS(N( RLtfinalize_offsetRFRNtmpl_disconnectRhRMRKRf(R>R(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRQ�s     cCs(x!|jD]}|jj|�q WdS(sdisconnect the callbacksN(RTRNRk(R>tcid((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt disconnect�scCs|jj|�S(N(RKRE(R>ReR[((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRS�scCsdS(N((R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRi�scCsdS(N((R>R\R]((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRZ�scCsdS(N((R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRj�s(RhRiRjRFR;R^RcRPRQRmRSRiRZRj(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRHis       tDraggableOffsetBoxcBs/eZed�Zd�Zd�Zd�ZRS(cCs#tj||d|�||_dS(NRU(RHR;R(R>RKRRU((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�scCsa|j}|jj}|j|�\}}}}|j|||||�}|\|_|_dS(N(RRFRaR[RQt offsetbox_xt offsetbox_y(R>RRPR%R4RYRZtoffset((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRi�s   cCs.|j||j|f}|jj|�dS(N(RoRpRRK(R>R\R]t loc_in_canvas((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRZ�sc CsW|j}|jj}|j|�\}}}}|j\}}||||f} | S(N(RRFRaR[R=( R>RRPR%R4RYRZRfRgRr((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pytget_loc_in_canvas�s   (RhRiRFR;RiRZRs(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRn�s   tDraggableAnnotationcBs/eZed�Zd�Zd�Zd�ZRS(cCs#tj||d|�||_dS(NRU(RHR;t annotation(R>RuRU((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyR;�sc Cs�|j}|j\}}t|jt�r�|j\}}|j|jj|||�\}}|j|jj|||�\}} || } } n'|j|jj|||j�\} } | | |_|_ d|j_dS(Ns figure pixels( RuRRoRR0R1RNRPRfRg( R>tannR5R6R7R8R9R:R;R<R=R>((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRi�s $$'cCsZ|j}|j||j|f|_|j\}}|j|jj|||j�}dS(N(RuRfRgRR1RNRPR(R>R\R]RvR5R6RJ((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRZs cCsL|jj}d|j_|jjjj�j|�}t|�|j_dS(Ns axes fraction(RuRRR�t transAxestinvertedttransform_pointR0(R>Rrtpos_axes_fraction((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRjs  (RhRiRFR;RiRZRj(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyRt�s   t__main__iiyiigp@R iR�Ridg�?R$iRRR%s offset pointsR�Rcg�������?R'tboxstyletroundtfcR6R�Rt arrowstyles->(idid(g�?g�?(ii(IRjtmatplotlib.transformst transformsR\tmatplotlib.artistReR?tmatplotlib.textttextR�tnumpyRRRRRRtmatplotlib.font_managerRtmatplotlib.patchesRRt matplotlibRR tmatplotlib.cbooktcbooktmatplotlib.imageR R R RFR R*R8R@R9RkRmRvRxR�R�R�R�R�RRtobjectRHRnRtRhtpltRFRCtclftsubplottaxReRtarangetreshapeRHRtmyimageR�RKtmyimage2R�RvRdtshow(((sG/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/offsetbox.pyt<module>sx ( / &oCCg�q�n�j