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

Skip to content

Commit bdd1cfe

Browse files
committed
hacky_fix_for_legend_typeerror_issue_10784
1 parent 24d530e commit bdd1cfe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ def _get_packed_offsets(wd_list, total, sep, mode="fixed"):
7777
return total, offsets
7878

7979
elif mode == "expand":
80+
# This is a bit of a hack to avoid a TypeError when *total*
81+
# is None and used in conjugation with tight layout.
82+
if total is None:
83+
total = 1
8084
if len(w_list) > 1:
81-
sep = (total - sum(w_list)) / (len(w_list) - 1.)
85+
sep = (total - sum(w_list)) / (len(w_list) - 1)
8286
else:
8387
sep = 0
8488
offsets_ = np.cumsum([0] + [w + sep for w in w_list])
8589
offsets = offsets_[:-1]
86-
# this is a bit of a hack to avoid a TypeError when used
87-
# in conjugation with tight layout
88-
if total is None:
89-
total = 1
9090
return total, offsets
9191

9292
elif mode == "equal":

0 commit comments

Comments
 (0)