Skip to content

Commit bf81d2b

Browse files
committed
Merge pull request #1864 from leejjoon/fix-legend-expand
fix legend w/ 'expand' mode which fails for a single item.
2 parents b062b50 + eb3ecb2 commit bf81d2b

File tree

5 files changed

+1177
-1
lines changed

5 files changed

+1177
-1
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def _get_packed_offsets(wd_list, total, sep, mode="fixed"):
7373
return total, offsets
7474

7575
elif mode == "expand":
76-
sep = (total - sum(w_list)) / (len(w_list) - 1.)
76+
if len(w_list) > 1:
77+
sep = (total - sum(w_list)) / (len(w_list) - 1.)
78+
else:
79+
sep = 0.
7780
offsets_ = np.add.accumulate([0] + [w + sep for w in w_list])
7881
offsets = offsets_[:-1]
7982

Binary file not shown.

0 commit comments

Comments
 (0)