diff --git a/lib/matplotlib/sankey.py b/lib/matplotlib/sankey.py index 0e1c1cd24df1..1e243e20fbd1 100644 --- a/lib/matplotlib/sankey.py +++ b/lib/matplotlib/sankey.py @@ -443,12 +443,14 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='', # In the code below, angles are expressed in deg/90. rotation /= 90.0 if orientations is None: - orientations = [0, 0] - if len(orientations) != n: + orientations = 0 + try: + orientations = np.broadcast_to(orientations, n) + except ValueError: raise ValueError( - "orientations and flows must have the same length.\n" - "orientations has length %d, but flows has length %d." - % (len(orientations), n)) + f"The shapes of 'flows' {np.shape(flows)} and 'orientations' " + f"{np.shape(orientations)} are incompatible" + ) from None if not cbook.is_scalar_or_string(labels) and len(labels) != n: raise ValueError( "If labels is a list, then labels and flows must have the "