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

Skip to content

Commit bdacdda

Browse files
committed
Broadcast 'orientations' arg to Sankey.add.
1 parent 7f4b044 commit bdacdda

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
@@ -443,12 +443,14 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
443443
# In the code below, angles are expressed in deg/90.
444444
rotation /= 90.0
445445
if orientations is None:
446-
orientations = [0, 0]
447-
if len(orientations) != n:
446+
orientations = 0
447+
try:
448+
orientations = np.broadcast_to(orientations, n)
449+
except ValueError:
448450
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))
451+
f"The shapes of 'flows' {np.shape(flows)} and 'orientations' "
452+
f"{np.shape(orientations)} are incompatible"
453+
) from None
452454
if not cbook.is_scalar_or_string(labels) and len(labels) != n:
453455
raise ValueError(
454456
"If labels is a list, then labels and flows must have the "

0 commit comments

Comments
 (0)
0