From bdacddac4c2435f88b15786d92cb73b479ad4164 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 17 Jan 2019 23:25:51 +0100 Subject: [PATCH] Broadcast 'orientations' arg to Sankey.add. --- lib/matplotlib/sankey.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 "