Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/matplotlib/__pycache__/sankey.cpython-37.pyc

372 lines
22 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
U<>]<5D><><00>@s<>dZddlZddlmZddlZddlmZddlm Z ddl
m Z ddl m Z ddl mZe<01>e<10>Zd Zd
gZd Zd ZdZd ZdZGdd<10>de<19>ZdS)z7
Module for creating Sankey diagrams using Matplotlib.
<EFBFBD>N)<01>SimpleNamespace)<01>Path)<01> PathPatch)<01>Affine2D)<01> docstring)<01>rcParamszKevin L. Daviesz Yannick CopinZBSDz
2011/09/16<31><00>c @sZeZdZdZdd d<0E>Zd dd<14>Zdd<16>Zdd<18>Zej fdd<1A>Z
e j d!dd<1C><01>Z dd<1E>ZdS)"<22>Sankeyab
Sankey diagram.
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) <https://en.wikipedia.org/wiki/Sankey_diagram>`_
N<><00>?<3F><00>%G<><00>?皙<><E79A99><EFBFBD><EFBFBD><EFBFBD>?<3F><><1E><>Q<EFBFBD><51>?<3F>333333<33>?<3F>d<><E79A99><EFBFBD><EFBFBD><EFBFBD>?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư>c Ks
|dkrtd<02><01>||kr td<03><01>| dkr0td<04><01>| dkr@td<05><01>|dkrpddlm} | <0A><03>}|jdddggd<08>}g|_||_||_||_||_ ||_
||_ ||_ ||_ |
|_t<0F>tjd| d d
<00>|_| |_t<0F>tjtj tjtj f<04>|_t| <0C><01>r|jf| <0C>dS) aH
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()
See Also
--------
Sankey.add
Sankey.finish
Examples
--------
.. plot:: gallery/specialty_plots/sankey_basics.py
rzS'gap' is negative, which is not allowed because it would cause the paths to overlapz`'radius' is greater than 'gap', which is not allowed because it would cause the paths to overlapzp'head_angle' is negative, which is not allowed because it would cause inputs to look like outputs and vice versaz3'tolerance' is negative, but it must be a magnitudeNr)ZxticksZyticksg<00>f@g@)<19>
ValueErrorZmatplotlib.pyplotZpyplot<6F>figureZ add_subplot<6F>diagrams<6D>ax<61>unit<69>format<61>scale<6C>gap<61>radius<75>shoulder<65>offset<65>margin<69>np<6E>tan<61>pi<70>pitch<63> tolerance<63>array<61>inf<6E>extent<6E>len<65>add)<0F>selfrrrrrrrrZ
head_angler r%<00>kwargsZpltZfig<69>r-<00>9/tmp/pip-install-i8dhxrtk/matplotlib/matplotlib/sankey.py<70>__init__*s>Q  
zSankey.__init__rTr<00>rrc
Cs"tjtjtjtjtjtjtjg}t<03>ddgddgddgddgddgddgddgg<07>}|dksd|dkr<>|rn|}q<>|d d <09>d d d
<EFBFBD>f}nf|d ks<>|d kr<>|r<>t<03>|d d <09>d f |d d <09>dff<02>}n(t<03>|d d <09>df |d d <09>d ff<02>}|d kr<>| }tt|||t<03>||j dd f<02><00><02>S) a=
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<00>?ggw,<2C><><EFBFBD><EFBFBD><EFBFBD>?g<><67><EFBFBD><EFBFBD>S<EFBFBD><53>?g<><67><02><><EFBFBD><EFBFBD>?g><3E>ef<65><66><EFBFBD>?r<00>N<><4E><EFBFBD><EFBFBD><EFBFBD>rr )
r<00>LINETO<54>CURVE4r!r&Z column_stack<63>list<73>zipZtile<6C>shape)r+<00>quadrant<6E>cwr<00>centerZ ARC_CODESZ ARC_VERTICES<45>verticesr-r-r.<00>_arc<72>s8
  z Sankey._arcc
Cs|dkrddgddgfS|dd\}}|d|j}|tkr<>||8}||||dg}|<01>tj||gftj|ftj|||gftj||j||gfg<04>|d|j|dg} <09>nJ||j8}|tkr<>d}
nd}
||d||
||g}|tk<02>rd} nd} |j <09>r@|<01>|j
| |tk|j ||j ||
|j fd<07><04>n|<01> tj||gf<02>|<01>tj|||
|gftj|ftj||||
|gfg<03>|<01>|j
| |tk||j ||j ||
|j fd<07><04>|<01> tj||||
|gf<02>|d|d|
|jg} || fSdS)zP
Add an input to a path and return its tip and label locations.
Nrr2rr1g@)r8r9rr:) r$<00>RIGHT<48>extendrr3rr<00>UP<55>DOWNrr<<00>append) r+<00>path<74>angle<6C>flow<6F>length<74>x<>yZdipdepthZdip<69>label_location<6F>signr8r-r-r.<00>
_add_input<EFBFBD>sL



 zSankey._add_inputc Csv|dkrddgddgfS|dd\}}|j|d|j}|tkr<>||7}||||dg}|<01>tj||gftj|||jgftj|ftj|||j|gftj|||gftj||j||gfg<06>|d|j|dg} <09>n<>||j7}|tk<02>rd}
nd}
||d||
||g}|tk<02>r0d} nd} |j <09>rp|<01>|j
| |tk|j ||j ||
|j fd<08><04>n|<01> tj||gf<02>|<01>tj|||
|gftj||j||
|gftj|ftj||j|||
|gftj||||
|gfg<05>|<01>|j
| |t k|j |||j ||
|j fd<08><04>|<01> tj||||
|gf<02>|d|d|
|jg} || fSdS) z<>
Append an output to a path and return its tip and label locations.
.. note:: *flow* is negative for an output.
Nrr2rr1g@r )r8r9rr:) rr$r=r>rr3rrr?rr<rAr@) r+rBrCrDrErFrGZ tipheight<68>tiprHrIr8r-r-r.<00> _add_outputsX



 
 zSankey._add_outputcCs:g}|}x,|ddd<02>D]\}}|<03>||f<02>|}qW|S)z<>
A path is not simply reversible by path[::-1] since the code
specifies an action to take from the **previous** point.
Nr2)rA)r+rBZ first_actionZ reverse_pathZ next_code<64>code<64>positionr-r-r.<00>_revertLs zSankey._revertc
6
s<>|dkrt<00>ddg<02>}n
t<00>|<02>}|jd} <0B>dkr:d<04>n<08>d<00>|dkrNd}yt<00>|| <0B>}Wn8tk
r<EFBFBD>tdt<00>|<02><01>dt<00>|<03><01>d<08><05>d<01>YnXyt<00>|| <0B>}Wn8tk
r<EFBFBD>tdt<00>|<02><01>d t<00>|<04><01>d<08><05>d<01>YnX|dkr<>td
<EFBFBD><01>t<00>t<00>|<02><01>|jk<04>rt<08> d t<00>|<02>|<01>|j
|} td d <0A>| D<00><01>} tdd <0A>| D<00><01>}|dk <09>r<>|dk<00>rhtd<0F><01>t |<08>dk<00>r~td<10><01>|t |j <0A>k<05>r<>td|<07>dt |j <0A><01>d<13><05><01>|dt |j |j<0E>k<05>r<>td<14>|dt |j |j<0E><01><02><01>|d| k<05>r td|d<00>d| <0B>d<18><05><01>|j |j|ddk<08>r@td|d<00>d|<07>d<1B><05><01>|j |j|d||d}t|<0F>|jk<05>r<>td|<0F>d|j<07>d<1E><05><01>dg| }xVt|<02>D]J\}}||jk<05>r<>d||<n*||j k<01>r<>d ||<nt<08> d!|||j<07><00>q<>Wdg| }x<>tt||<10><02>D]<5D>\}\}}|dk<02>r:|<15>r*t||<n|<15>s<>t||<n\|dk<02>rX|dk <09>r<>t||<n>|d"k<03>rxtd#|<11>d$|<14>d%<25><05><01>|<15>r<>t||<n|<15>st||<<00>qWt<00>|<06><01>r<>t |<06>| k<03>r<>td&| <0B>d't |<06><01>d(<28><05><01><01>n<>|}|}|}|}t|d)<29><01><01>fd*d+<2B>|D<00>}xftt||| <0C><03>D]R\}\}}}|tk<02>rB|<15>rB|||<||7}n |tk<02>r|<15>s|||<||8}<16>qWx~tttt||| <0C><03><01><01>D]b\}\}}}|tk<02>r<>|<15>r<>||| |d<||7}n(|tk<02>r<>|<15>s<>||| |d<||8}<18>q<>Wd }x^tttt||t| |<06><02><03><01><01>D]<\}\}}}|tk<02>r |<15>r |<1B>rBd|| |d<nd}<1B>q Wd }xRtt||tt| |<06><02><01><03>D]4\}\}}}|tk<02>rl|<15>sl|<1D>r<>d||<nd}<1D>qlWtj|j|d,| d,gftj|j|d,d,| d,gftj|j|d,d-| d,gftj|d,|jd-| d,gftj|d,|jd,| d,gftj|d,|j| d,gfg}tj|d,|j|d,gftj|d,|jd,|d,gftj|d,|jd-|d,gftj|j|d,d-| d,gftj|j|d,d,| d,gftj|j|d,| d,gfg}tj|d,|j|d,gfg} tj|j|d,| d,gfg}!t<00>| d.f<02>}"t<00>| d.f<02>}#x<>tt||tt| |<06><02><01><03>D]<5D>\}\}}}|tk<02>r<>|<15>r<>|j |!|f|<1C><02>\|"|dd<01>f<|#|dd<01>f<n>|tk<02>r<>|<15>s<>|j!||f|<1C><02>\|"|dd<01>f<|#|dd<01>f<<00>q<>Wx<>tttt||tt| |<06><02><01><03><01><01>D]<5D>\}\}}}|tk<02>r<>|<15>r<>|j ||f|<1C><02>\}$}%|$|"| |ddd<01>f<|%|#| |ddd<01>f<nV|tk<02>r:|<15>s:|j!| |f|<1C><02>\}$}%|$|"| |ddd<01>f<|%|#| |ddd<01>f<<00>q:Wd }x<>tttt||tt| |<06><02><01><03><01><01>D]<5D>\}\}}}|tk<02> r$|<15> r$|<1B> s<>|d"dd|!d"ddk<04> r<>|<1F>"tj|!d"dd|d"ddgf<02>d}|j ||f|<1C><02>\}$}%|$|"| |ddd<01>f<|%|#| |ddd<01>f<<00> q$Wd }x<>tt||tt| |<06><02><01><03>D]<5D>\}\}}}|tk<02>
r|<15>
s|<1D>
s||d"dd| d"ddk<00>
rx|<1E>"tj| d"dd|d"ddgf<02>d}|j!||f|<1C><02>\|"|dd<01>f<|#|dd<01>f<<00>
qW|<1B>
s<EFBFBD>|!<21>#<23>|<1F>#<23>|<1D>
s<EFBFBD>| <20>#<23>|<1E>#<23>||<00>$| <20>||<00>$|!<21>tj%|ddfg}&t|&<26>\}'}(t<00>|(<28>}(d/d0<64><00>|dk<08> r<><72>dk<03> r|<7C><00>fd1d+<2B>|D<00>}t&<26><00>'<27>d2<00>j(})|)|"<22>}"|)|#<23>}#|)|(<28>}(|j)j*dd|d3d3d4<64>}*n<>|j |j|d||d<00><02><00>fd5d+<2B>|D<00>}t&<26><00>'<27>d2<00>j(})|)|"<22>}"|j |j+|d|"|d}+t&<26>j,|+<2B>j(},|,|"<22>}"|,|)|#<23><01>}#|,|)|(<28><01>}(t|d3d3d4<64>}-|j)j*|+|-<2D>}*t-d6<00> r<>|
<EFBFBD>#d7|
<EFBFBD>#d8d9<64><02>}.|
<EFBFBD>#d:|
<EFBFBD>#d;d<<3C><02>}/n(|
<EFBFBD>#d7|
<EFBFBD>#d8d<01><02>}.|
<EFBFBD>#d:|
<EFBFBD>#d;d<01><02>}/|.dk<08> r<>t.|j)j/j0<6A>d=}.t1t|(|'<27>f|.|/d><3E>|
<EFBFBD><02>}0|j)<29>2|0<>g}1x<31>t||||#<23>D]<5D>\}2}}3}4|3dk<08> s |dk<08> r&d?}3n:|j3dk <09> r`|jt|2<>|j3}5|3d?k<03> rX|3d@7}3|3|57}3|1<>"|j)j*|4d|4d|3d3d3dA<64><05><00> qWt t<00> |(dd<01>df<00>t<00> |#dd<01>df<00>|j4d<00>t5t<00>5|(dd<01>df<00>t<00>5|#dd<01>df<00>|j4d<00>t t<00> |(dd<01>df<00>t<00> |#dd<01>df<00>|j4d.<00>t5t<00>5|(dd<01>df<00>t<00>5|#dd<01>df<00>|j4dB<00>f|_4|j <0A>"t6|0|||"|*|1dC<64><06>|S)Da<44>
Add a simple Sankey diagram with flows at the same hierarchical level.
Parameters
----------
patchlabel : str
Label to be placed at the center of the diagram.
Note that *label* (not *patchlabel*) can be passed as keyword
argument to create an entry in the legend.
flows : list of float
Array of flow values. By convention, inputs are positive and
outputs are negative.
Flows are placed along the top of the diagram from the inside out
in order of their index within *flows*. They are placed along the
sides of the diagram from the top down and along the bottom from
the outside in.
If 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.
orientations : list of {-1, 0, 1}
List of orientations of the flows (or a single orientation to be
used for all flows). Valid values are 0 (inputs from
the left, outputs to the right), 1 (from and to the top) or -1
(from and to the bottom).
labels : list of (str or None)
List of labels for the flows (or a single label to be used for all
flows). Each label may be *None* (no label), or a labeling string.
If an entry is a (possibly 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 : float
Length between the bases of the input and output groups (in
data-space units).
pathlengths : list of float
List of lengths of the vertical 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 : int
Index of the prior diagram to which this diagram should be
connected.
connect : (int, int)
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 : float
Angle of rotation of the diagram in degrees. 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). *rotation* is ignored if this diagram is connected to an
existing one (using *prior* and *connect*).
Returns
-------
Sankey
The current `.Sankey` instance.
Other Parameters
----------------
**kwargs
Additional keyword arguments set `matplotlib.patches.PathPatch`
properties, listed below. For example, one may want to use
``fill=False`` or ``label="A legend entry"``.
%(Patch)s
See Also
--------
Sankey.finish
Ng<00>?g<00><>rg<00>V@zThe shapes of 'flows' z and 'orientations' z are incompatiblez and 'labels' zR'trunklength' is negative, which is not allowed because it would cause poor layoutzWThe sum of the flows is nonzero (%f; patchlabel=%r); is the system not at steady state?css|]}t|d<00>VqdS)rN)<01>max)<02>.0rDr-r-r.<00> <genexpr><3E>szSankey.add.<locals>.<genexpr>css|]}t|d<00>VqdS)rN)<01>min)rQrDr-r-r.rR<00>sz*The index of the prior diagram is negativez2At least one of the connection indices is negativez"The index of the prior diagram is z, but there are only z other diagramszTThe connection index to the source diagram is {}, but that diagram has only {} flowsrz(The connection index to this diagram is z, but this diagram has only z flowszHThe connection cannot be made, which may occur if the magnitude of flow z of diagram z% is less than the specified tolerancez)The scaled sum of the connected flows is z%, which is not within the tolerance (<28>)TFzwThe magnitude of flow %d (%f) is below the tolerance (%f).
It will not be shown, and it cannot be used in a connection.r2zThe value of orientations[z] is z, but it must be -1, 0, or 1zThe lengths of 'flows' (z) and 'pathlengths' (z) are incompatible)r=csg|]}<01><00>|d<00><02>qS)r)<01>get)rQrC)<01>dr-r.<00>
<listcomp>(szSankey.add.<locals>.<listcomp>g@g @r1cSs|dkr dS||SdS)Nr-)<02>a<>rr-r-r.<00>
_get_angle<EFBFBD>szSankey.add.<locals>._get_anglecsg|]}<01>|<01><01><02>qSr-r-)rQrC)rZ<00>rotationr-r.rW<00>s<00>Zr:)<03>s<>ha<68>vacsg|]}<01>|<01><01><02>qSr-r-)rQrC)rZr[r-r.rW<00>sz_internal.classic_mode<64>fcZ facecolorz#bfd1d4<64>lwZ linewidthg<00>?<3F>color)r`rar <00>
)rFrGr]r^r_r )<06>patch<63>flows<77>angles<65>tips<70>text<78>texts)7r!r&r7Z broadcast_tor<00>abs<62>sumr%<00>_log<6F>inforrSr)rrerrf<00> enumerater6r@r?r=<00>iterable<6C>dict<63>reversedr5rZMOVETOrr3r4<00>zerosrJrLrA<00>poprOZ CLOSEPOLYrZ
rotate_degZtransform_affinerrhrg<00> translater<00>nextZ_get_patches_for_fillZ prop_cyclerrZ add_patchrr(rPr)6r+Z
patchlabelreZ orientations<6E>labelsZ trunklengthZ pathlengthsZprior<6F>connectr[r,<00>nZ scaled_flowsZgainZlossZ
flow_errorZ
are_inputs<EFBFBD>irDrfZorientZis_inputZurlengthZullengthZlrlengthZlllengthrCZhas_left_input<75>specZhas_right_outputZurpathZllpathZlrpathZulpathrgZlabel_locationsrKrHrB<00>codesr;<00>rotaterhrrt<00>kwdsr`rardri<00>number<65>label<65>locationZquantityr-)rZrVr[r.r*^s W







 










 





$

$





  


  $,0
(
("$"0 


   

 
 




 z
Sankey.addcCsZ|j<00>|jd|j|jd|j|jd|j|jd|jg<04>|jjddd<07>|jS)a<>
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:`~matplotlib.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
=============== ===================================================
See Also
--------
Sankey.add
rrr1r <00>equalZdatalim)Z
adjustable)rZaxisr(r Z
set_aspectr)r+r-r-r.<00>finishs 'z Sankey.finish) Nr r r rrrrrrr)rTrr0) r NNr r rNr0r)<0F>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r/r<rJrLrr3rOrZdedent_interpdr*r<>r-r-r-r.r
s 

{
74: )r
)r<><00>logging<6E>typesrZnumpyr!Zmatplotlib.pathrZmatplotlib.patchesrZmatplotlib.transformsrZ
matplotlibrr<00> getLoggerr<72>rl<00>
__author__<EFBFBD> __credits__<5F> __license__<5F> __version__r=r?r@<00>objectr
r-r-r-r.<00><module>s"