ó ù)°Uc@ s¢dZddlmZddlZejZddljZddlZ de fd„ƒYZ de fd„ƒYZ de fd „ƒYZ d e fd „ƒYZdS( sÍ :mod:`~matplotlib.gridspec` is a module which specifies the location of the subplot in the figure. ``GridSpec`` specifies the geometry of the grid that a subplot will be placed. The number of rows and number of columns of the grid need to be set. Optionally, the subplot layout parameters (e.g., left, right, etc.) can be tuned. ``SubplotSpec`` specifies the location of the subplot in the given *GridSpec*. iÿÿÿÿ(tdivisionNt GridSpecBasecB sweZdZd d d„Zd„Zd d„Zddd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( sm A base class of GridSpec that specifies the geometry of the grid that a subplot will be placed. cC s1|||_|_|j|ƒ|j|ƒdS(s· The number of rows and number of columns of the grid need to be set. Optionally, the ratio of heights and widths of ros and columns can be specified. N(t_nrowst_ncolstset_height_ratiostset_width_ratios(tselftnrowstncolst height_ratiost width_ratios((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyt__init__ s cC s|j|jfS(s$get the geometry of the grid, eg 2,3(RR(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyt get_geometry-scC sdS(N((Rtfig((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pytget_subplot_params1sicC s4|\}}||||…|||…f}|S(s: create and return a SuplotSpec instance. ((Rtloctrowspantcolspantloc1tloc2t subplotspec((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pytnew_subplotspec4s $cC s ||_dS(N(t_col_width_ratios(RR ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyR=scC s|jS(N(R(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pytget_width_ratios@scC s ||_dS(N(t_row_height_ratios(RR ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRCscC s|jS(N(R(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pytget_height_ratiosFsc!C s«|jƒ\}}|j|ƒ}|j}|j}|j}|j}|j} |j} ||} ||} | || |d} | | }|jdk rà| |}t t |jƒƒ}g|jD]}|||^qÃ}n | g|}dg|g|d}t j jt jt||ƒƒƒ}| || |d}| |}|jdk rž||}t t |jƒƒ}g|jD]}|||^q}n |g|}dg|g|d}t j jt jt||ƒƒƒ}gt|ƒD]}||d|^qô}gt|ƒD]}||d|d^q}gt|ƒD]}||d|^qN}gt|ƒD]}||d|d^qy} |||| fS(so return lists of bottom and top position of rows, left and right positions of columns. iiiN(R RtlefttrighttbottomttoptwspacethspaceRtNonetfloattsumtnptaddt accumulatetraveltzipRtrange(!RR RRtsubplot_paramsRRRRRRttotWidtht totHeighttcellHtsepHt netHeightttrtrt cellHeightst sepHeightstcellHstcellWtsepWtnetWidtht cellWidthst sepWidthstcellWstrowNumtfigTopst figBottomstcolNumtfigLeftst figRights((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pytget_grid_positionsJsB          ' $  ' $+/+/cC s”|jƒ\}}||}t|tƒr*y|\}}Wntk rZtdƒ‚nXt|tƒr…|j|ƒ\}}} n*|dkrž||7}n||d}}t|tƒrÙ|j|ƒ\} } } n*|dkrò||7}n||d} } ||| } |d|| d} nZt|tƒr^|j|ƒ\} } } | d8} n&|dkrw||7}n|d} } t|| | ƒS(s: create and return a SuplotSpec instance. sunrecognized subplot speciiN(R t isinstancettuplet ValueErrortslicetindicesR t SubplotSpec(RtkeyRRttotaltk1tk2trow1trow2t_tcol1tcol2tnum1tnum2((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyt __getitem__ƒs4          N(t__name__t __module__t__doc__R R R RRRRRRR@RR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRs       9tGridSpecc B s\eZdZd d d d d d d d d„ZddddddgZd„Zd d „ZRS( s¨ A class that specifies the geometry of the grid that a subplot will be placed. The location of grid is determined by similar way as the SubplotParams. c C sY||_||_||_||_||_||_tj|||d| d| ƒdS(s¸ The number of rows and number of columns of the grid need to be set. Optionally, the subplot layout parameters (e.g., left, right, etc.) can be tuned. R R N(RRRRRRRR ( RRRRRRRRRR R ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyR ¸s      RRRRRRcK saxO|jƒD]A\}}||jkr;t|||ƒq td|fƒ‚q Wddlm}ddlm}xè|jj j ƒD]Ô}xË|j j j D]º}t||ƒs;|jdk rôt|j|ƒrô|jjƒ|j|jjƒqU|jdk rUt|j|ƒrU|jjƒ|j|jjƒqUq›|jƒ|j|jƒq›Wq…WdS(s‚ Update the current values. If any kwarg is None, default to the current value, if set, otherwise to rc. s%s is unknown keywordiÿÿÿÿ(t_pylab_helpers(t SubplotBaseN(titemst _AllowedKeystsetattrtAttributeErrort matplotlibRWtmatplotlib.axesRXtGcftfigstvaluestcanvastfiguretaxesRAt_sharexR t update_paramst set_positiontfigboxt_sharey(RtkwargstktvRWRXt figmanagertax((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pytupdateÒs"! !  cC s»ddlm}ddl}|dkrgtg|jD]}|td|f^q5ƒ}||}n|j|jƒ}tg|jD]}|t||ƒf^q†ƒ}|j ||S(s– return a dictionary of subplot layout parameters. The default parameters are from rcParams unless a figure attribute is set. iÿÿÿÿ(t SubplotParamsNsfigure.subplot.( tmatplotlib.figureRptcopyR tdictRZtrcParamst subplotparstgetattrRo(RR RpRrRktkwRut update_kw((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRòs  *1 N(RSRTRUR R RZRoR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRV±s  tGridSpecFromSubplotSpeccB s/eZdZddddd„Zdd„ZRS(sx GridSpec whose subplot layout parameters are inherited from the location specified by a given SubplotSpec. cC s>||_||_||_tj|||d|d|ƒdS(s` The number of rows and number of columns of the grid need to be set. An instance of SubplotSpec is also needed to be set from which the layout parameters will be inheirted. The wspace and hspace of the layout can be optionally specified or the default values (from the figure or rcParams) will be used. R R N(t_wspacet_hspacet _subplot_specRR (RRRt subplot_specRRR R ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyR s   c C sß|d kr#td}td}n|jj}|jj}|jd k rV|j}n|jd k rq|j}n|jj|dt ƒ}|j \}}}}ddl m } | d|d|d|d |d |d |ƒ} | S( sC return a dictionary of subplot layout parameters. sfigure.subplot.hspacesfigure.subplot.wspacet return_alliÿÿÿÿ(RpRRRRRRN( R RtRuRRR{RzR|t get_positiontFalsetextentsRqRp( RR RRRhRRRRRptsp((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyR s&         N(RSRTRUR R R(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRysRFcB s8eZdZdd„Zd„Zd„Zed„ZRS(sH specifies the location of the subplot in the given *GridSpec*. cC s;|jƒ\}}||}||_||_||_dS(sÕ The subplot will occupy the num1-th cell of the given gridspec. If num2 is provided, the subplot will span between num1-th cell and num2-th cell. The index stars from 0. N(R t _gridspecRPRQ(RtgridspecRPRQtrowstcolsRH((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyR Hs    cC s|jS(N(Rƒ(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyt get_gridspecXscC s.|jƒjƒ\}}|||j|jfS(sc get the subplot geometry, eg 2,2,3. Unlike SuplorParams, index is 0-based (R‡R RPRQ(RR…R†((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyR \scC sC|jƒ}|jƒ\}}|j|ƒ\}}}} t|j|ƒ\} } || } || } || }| | }|jdk rt|j|ƒ\}}||}||}||}| |}t| |ƒ} t||ƒ}t| |ƒ} t||ƒ}nt j j || || ƒ}|r;|| | ||fS|SdS(sB update the subplot position from fig.subplotpars N( R‡R R@tdivmodRPRQR tmintmaxt mtransformstBboxt from_extents(RR R~R„RRR<R;R>R?R:R=t figBottomtfigToptfigLefttfigRighttrowNum2tcolNum2t figBottom2tfigTop2tfigLeft2t figRight2Rh((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRes.          N( RSRTRUR R R‡R R€R(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyRFCs    (RUt __future__RR]Rttmatplotlib.transformst transformsR‹tnumpyR#tobjectRRVRyRF(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/gridspec.pyts   —U=