Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f813278

Browse files
committed
In Sankey, prevented appended lists of labels
1 parent 80f3030 commit f813278

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

lib/matplotlib/sankey.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -755,22 +755,18 @@ def _get_angle(a, r):
755755
self.ax.add_patch(patch)
756756

757757
# Add the path labels.
758-
for i, (number, angle) in enumerate(zip(flows, angles)):
759-
if labels[i] is None or angle is None:
760-
labels[i] = ''
758+
texts = []
759+
for i, (number, angle, label, location) in enumerate(zip(flows, angles,
760+
labels, label_locations)):
761+
if label is None or angle is None:
762+
label = ''
761763
elif self.unit is not None:
762764
quantity = self.format % abs(number) + self.unit
763-
if labels[i] != '':
764-
labels[i] += "\n"
765-
labels[i] += quantity
766-
texts = []
767-
for i, (label, location) in enumerate(zip(labels, label_locations)):
768-
if label:
769-
s = label
770-
else:
771-
s = ''
765+
if label != '':
766+
label += "\n"
767+
label += quantity
772768
texts.append(self.ax.text(x=location[0], y=location[1],
773-
s=s,
769+
s=label,
774770
ha='center', va='center'))
775771
# Text objects are placed even they are empty (as long as the magnitude
776772
# of the corresponding flow is larger than the tolerance) in case the

0 commit comments

Comments
 (0)