8000 fix some warnings and errors in sankey docstrings · cirosantilli/matplotlib@a9e32ab · GitHub
[go: up one dir, main page]

Skip to content

Commit a9e32ab

Browse files
committed
fix some warnings and errors in sankey docstrings
1 parent 713e0bc commit a9e32ab

File tree

1 file changed

+44
-49
lines changed

1 file changed

+44
-49
lines changed

lib/matplotlib/sankey.py

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
2-
"""Module for creating Sankey diagrams using matplotlib
2+
"""
3+
Module for creating Sankey diagrams using matplotlib
34
"""
45
__author__ = "Kevin L. Davies"
56
__credits__ = ["Yannick Copin"]
@@ -40,6 +41,7 @@
4041
from matplotlib.patches import PathPatch
4142
from matplotlib.transforms import Affine2D
4243
from matplotlib import verbose
44+
from matplotlib import docstring
4345

4446
# Angles [deg/90]
4547
RIGHT = 0
@@ -49,20 +51,18 @@
4951

5052

5153
class Sankey:
52-
"""Sankey diagram in matplotlib
54+
"""
55+
Sankey diagram in matplotlib
5356
54-
"Sankey diagrams are a specific type of flow diagram, in which the width of
55-
the arrows is shown proportionally to the flow quantity. They are typically
56-
used to visualize energy or material or cost transfers between processes."
57+
Sankey diagrams are a specific type of flow diagram, in which
58+
the width of the arrows is shown proportionally to the flow
59+
quantity. They are typically used to visualize energy or
60+
material or cost transfers between processes.
61+
`Wikipedia (6/1/2011) <http://en.wikipedia.org/wiki/Sankey_diagram>`_
5762
58-
--http://en.wikipedia.org/wiki/Sankey_diagram, accessed 6/1/2011
5963
"""
6064
def _arc(self, quadrant=0, cw=True, radius=1, center=(0,0)):
6165
"""
62-
call signature::
63-
64-
_arc(quadrant=0, cw=True, radius=1, center=(0,0))
65-
6666
Return the codes and vertices for a rotated, scaled, and translated
6767
90 degree arc.
6868
@@ -115,7 +115,8 @@ def _arc(self, quadrant=0, cw=True, radius=1, center=(0,0)):
115115
np.tile(center, (ARC_VERTICES.shape[0], 1)))
116116

117117
def _add_input(self, path, angle, flow, length):
118-
"""Add an input to a path and return its tip and label locations.
118+
"""
119+
Add an input to a path and return its tip and label locations.
119120
"""
120121
if angle is None:
121122
return [0, 0], [0, 0]
@@ -161,7 +162,8 @@ def _add_input(self, path, angle, flow, length):
161162
return dip, label_location
162163

163164
def _add_output(self, path, angle, flow, length):
164-
"""Append an output to a path and return its tip and label locations.
165+
"""
166+
Append an output to a path and return its tip and label locations.
165167
166168
Note: *flow* is negative for an output.
167169
"""
@@ -215,7 +217,8 @@ def _add_output(self, path, angle, flow, length):
215217
return tip, label_location
216218

217219
def _revert(self, path, first_action=Path.LINETO):
218-
"""A path is not simply revertable by path[::-1] since the code
220+
"""
221+
A path is not simply revertable by path[::-1] since the code
219222
specifies an action to take from the **previous** point.
220223
"""
221224
reverse_path = []
@@ -231,16 +234,11 @@ def _revert(self, path, first_action=Path.LINETO):
231234
#path[2] = path[2][::-1]
232235
#return path
233236

237+
@docstring.dedent_interpd
234238
def add(self, patchlabel='', f 8000 lows=np.array([1.0,-1.0]), orientations=[0,0],
235239
labels='', trunklength=1.0, pathlengths=0.25, prior=None,
236240
connect=(0,0), rotation=0, **kwargs):
237241
"""
238-
call signature::
239-
240-
add(patchlabel='', flows=np.array([1.0,-1.0]), orientations=[0,0],
241-
labels='', trunklength=1.0, pathlengths=0.25, prior=None,
242-
connect=(0,0), rotation=0, **kwargs)
243-
244242
Add a simple Sankey diagram with flows at the same hierarchical level.
245243
246244
Return value is the instance of :class:`Sankey`.
@@ -252,7 +250,7 @@ def add(self, patchlabel='', flows=np.array([1.0,-1.0]), orientations=[0,0],
252250
=============== ==========================================================
253251
*patchlabel* label to be placed at the center of the diagram
254252
Note: *label* (not *patchlabel*) will be passed to
255-
the patch through **kwargs and can be used to create
253+
the patch through `**kwargs` and can be used to create
256254
an entry in the legend.
257255
*flows* array of flow values
258256
By convention, inputs are positive and outputs are
@@ -297,9 +295,11 @@ def add(self, patchlabel='', flows=np.array([1.0,-1.0]), orientations=[0,0],
297295
=============== ==========================================================
298296
299297
Valid kwargs are :meth:`matplotlib.patches.PathPatch` arguments:
300-
%(PathPatch)s
301-
As examples, *fill*=False and *label*="A legend entry". By default,
302-
*facecolor*='#bfd1d4' (light blue) and *lineweight*=0.5.
298+
299+
%(Patch)s
300+
301+
As examples, `fill=False` and `label='A legend entry'`. By default,
302+
*facecolor*='#bfd1d4'` (light blue) and *linewidth*=0.5.
303303
304304
The indexing parameters (*prior* and *connect*) are zero-based.
305305
@@ -508,7 +508,7 @@ def add(self, patchlabel='', flows=np.array([1.0,-1.0]), orientations=[0,0],
508508
label_locations = np.zeros((n,2))
509509
# Add the top-side inputs and outputs from the middle outwards.
510510
for i, (angle, is_input, spec) \
511-
in enumerate(zip(angles, are_inputs,
511+
in enumerate(zip(angles, are_inputs,
512512
zip(scaled_flows, pathlengths))):
513513
if angle == DOWN and is_input:
514514
tips[i,:], label_locations[i,:] = self._add_input(ulpath, angle,
@@ -655,10 +655,6 @@ def _get_angle(a, r):
655655

656656
def finish(self):
657657
"""
658-
call signature::
659-
660-
finish()
661-
662658
Adjust the axes and return a list of information about the Sankey
663659
subdiagram(s).
664660
@@ -707,15 +703,7 @@ def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25,
707703
radius=0.1, shoulder=0.03, offset=0.15, head_angle=100,
708704
margin=0.4, tolerance=1e-6, **kwargs):
709705
"""
710-
call signature::
711-
712-
Sankey(ax=None, scale=1.0, unit='', format='%G', gap=0.25, radius=0.1,
713-
shoulder=0.03, offset=0.15, head_angle=100, margin=0.4,
714-
tolerance=1e-6, **kwargs)
715-
716-
Create a new Sankey diagram.
717-
718-
Return value is an instance of :class:`Sankey`.
706+
Create a new Sankey instance.
719707
720708
Optional keyword arguments:
721709
@@ -758,21 +746,28 @@ def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25,
758746
that there is consistent alignment and formatting.
759747
760748
If :class:`Sankey` is instantiated with any keyword arguments other than
761-
those explicitly listed above (**kwargs), they will be passed to
749+
those explicitly listed above (`**kwargs`), they will be passed to
762750
:meth:`add`, which will create the first subdiagram.
763751
764752
In order to draw a complex Sankey diagram, create an instance of
765-
:class:`Sankey` by calling it without any kwargs:
766-
>>> sankey = Sankey()
767-
Then add simple Sankey sub-diagrams:
768-
>>> sankey.add() # 1
769-
>>> sankey.add() # 2
770-
>>> #...
771-
>>> sankey.add() # n
772-
Finally, create the full diagram:
773-
>>> sankey.finish()
774-
Or, instead, simply daisy-chain those calls:
775-
>>> Sankey().add().add... .add().finish()
753+
:class:`Sankey` by calling it without any kwargs::
754+
755+
sankey = Sankey()
756+
757+
Then add simple Sankey sub-diagrams::
758+
759+
sankey.add() # 1
760+
sankey.add() # 2
761+
#...
762+
sankey.add() # n
763+
764+
Finally, create the full diagram::
765+
766+
sankey.finish()
767+
768+
Or, instead, simply daisy-chain those calls::
769+
770+
Sankey().add().add... .add().finish()
776771
777772
.. seealso::
778773

0 commit comments

Comments
 (0)
0