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

Skip to content

Commit 5c69eca

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

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 0 (inputs from the left, outputs
374+
to the right), 1 (from and to the top) or -1 (from
375+
and 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 'orientations' "
451+
f"{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