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

Skip to content

Commit b8ebabe

Browse files
committed
Merged revisions 7607 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7607 | leejjoon | 2009-08-30 20:32:12 -0400 (Sun, 30 Aug 2009) | 1 line fix sf bug #2839919 ........ svn path=/trunk/matplotlib/; revision=7608
1 parent c7f9008 commit b8ebabe

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/matplotlib/legend.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,9 @@ def _init_legend_box(self, handles, labels):
591591
# We calculate number of lows in each column. The first
592592
# (num_largecol) columns will have (nrows+1) rows, and remaing
593593
# (num_smallcol) columns will have (nrows) rows.
594-
nrows, num_largecol = divmod(len(handleboxes), self._ncol)
595-
num_smallcol = self._ncol-num_largecol
594+
ncol = min(self._ncol, len(handleboxes))
595+
nrows, num_largecol = divmod(len(handleboxes), ncol)
596+
num_smallcol = ncol-num_largecol
596597

597598
# starting index of each column and number of rows in it.
598599
largecol = safezip(range(0, num_largecol*(nrows+1), (nrows+1)),
@@ -860,3 +861,4 @@ def _find_best_position(self, width, height, renderer, consider=None):
860861

861862
return ox, oy
862863

864+

0 commit comments

Comments
 (0)