Skip to content

Commit 0dac001

Browse files
authored
Merge pull request #13213 from anntzer/sankey
Broadcast 'orientations' arg to Sankey.add.
2 parents 634e3db + bdacdda commit 0dac001

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/matplotlib/sankey.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,14 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
442442
# In the code below, angles are expressed in deg/90.
443443
rotation /= 90.0
444444
if orientations is None:
445-
orientations = [0, 0]
446-
if len(orientations) != n:
445+
orientations = 0
446+
try:
447+
orientations = np.broadcast_to(orientations, n)
448+
except ValueError:
447449
raise ValueError(
448-
"orientations and flows must have the same length.\n"
449-
"orientations has length %d, but flows has length %d."
450-
% (len(orientations), n))
450+
f"The shapes of 'flows' {np.shape(flows)} and 'orientations' "
451+
f"{np.shape(orientations)} are incompatible"
452+
) from None
451453
if not cbook.is_scalar_or_string(labels) and len(labels) != n:
452454
raise ValueError(
453455
f"The lengths of 'flows' ({n}) and 'labels' ({len(labels)}) "

0 commit comments

Comments
 (0)