8000 Broadcast 'orientations' arg to Sankey.add and fix its doc. · matplotlib/matplotlib@d13dfa1 · GitHub
[go: up one dir, main page]

Skip to content

Commit d13dfa1

Browse files
committed
Broadcast 'orientations' arg to Sankey.add and fix its doc.
1 parent 7f4b044 commit d13dfa1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/matplotlib/sankey.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,9 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
370370
By convention, inputs are positive and outputs are
371371
negative.
372372
*orientations* list of orientations of the paths
373-
Valid values are 1 (from/to the top), 0 (from/to
374-
the left or right), or -1 (from/to the bottom). If
375-
*orientations* == 0, inputs will break in from the
376-
left and outputs will break away to the right.
373+
Valid values are 1 (from/to the top), 0 (inputs
374+
from the left, outputs to the right), or -1
375+
(from/to the bottom).
377376
*labels* list of specifications of the labels for the flows
378377
Each value may be *None* (no labels), '' (just
379378
label the quantities), or a labeling string. If a
@@ -443,12 +442,14 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
443442
# In the code below, angles are expressed in deg/90.
444443
rotation /= 90.0
445444
if orientations is None:
446-
orientations = [0, 0]
447-
if len(orientations) != n:
445+
orientations = 0
446+
try:
447+
orientations = np.broadcast_to(orientations, n)
448+
except ValueError:
448449
raise ValueError(
449-
"orientations and flows must have the same length.\n"
450-
"orientations has length %d, but flows has length %d."
451-
% (len(orientations), n))
450+
f"The shapes of 'flows' ({np.shape(flows)}) and "
451+
f"'orientations' ({np.shape(orientations)}) are incompatible"
452+
) from None
452453
if not cbook.is_scalar_or_string(labels) and len(labels) != n:
453454
raise ValueError(
454455
"If labels is a list, then labels and flows must have the "

0 commit comments

Comments
 (0)
0