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

Skip to content

Commit 0bc3c49

Browse files
committed
FIX: fix bug added in last bugfix
1 parent ed91e98 commit 0bc3c49

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/matplotlib/legend_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def get_sizes(self, legend, orig_handle,
306306
xdescent, ydescent, width, height, fontsize):
307307
if self._sizes is None:
308308
handle_sizes = orig_handle.get_sizes()
309-
if not handle_sizes:
309+
if not len(handle_sizes):
310310
handle_sizes = [1]
311311
size_max = max(handle_sizes) * legend.markerscale ** 2
312312
size_min = min(handle_sizes) * legend.markerscale ** 2

lib/matplotlib/tests/test_legend.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ def test_nanscatter():
249249

250250
ax.legend([h], ["scatter"])
251251

252+
fig, ax = plt.subplots()
253+
for color in ['red', 'green', 'blue']:
254+
n = 750
255+
x, y = np.random.rand(2, n)
256+
scale = 200.0 * np.random.rand(n)
257+
ax.scatter(x, y, c=color, s=scale, label=color,
258+
alpha=0.3, edgecolors='none')
259+
260+
ax.legend()
261+
ax.grid(True)
262+
252263

253264
if __name__ == '__main__':
254265
import nose

0 commit comments

Comments
 (0)