burak1000
2015-04-21 20:32:59 UTC
Hi all,
I believe I've found a bug in scatter function in matplotlib 1.4.2:
from numpy import *
import matplotlib
from matplotlib.pyplot import *
figure()
subplot(111)
h = scatter([NAN], [NAN], marker="o", facecolor="r", edgecolor="r", s=3)
legend([h], ["scatter"])
savefig("out.png")
close()
The code above fails with ValueError exception:
Traceback (most recent call last):
File "legend.py", line 9, in <module>
legend([h], ["scatter"])
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/pyplot.py",
line 3381, in legend
ret = gca().legend(*args, **kwargs)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axes.py",
line 4778, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend.py",
line 366, in __init__
self._init_legend_box(handles, labels)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend.py",
line 630, in _init_legend_box
handlebox)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend_handler.py",
line 103, in __call__
handlebox.get_transform())
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend_handler.py",
line 325, in create_artists
width, height, fontsize)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend_handler.py",
line 282, in get_sizes
size_max = max(orig_handle.get_sizes()) * legend.markerscale ** 2
ValueError: max() arg is an empty sequence
There is some more information and the source of the problem described here:
http://stackoverflow.com/questions/29743696/legends-for-scatter-plots-with-nans-in-matplotlib
Thanks,
Tomasz
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Problem-creating-legend-for-scatter-plot-with-NANs-tp45419.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
I believe I've found a bug in scatter function in matplotlib 1.4.2:
from numpy import *
import matplotlib
from matplotlib.pyplot import *
figure()
subplot(111)
h = scatter([NAN], [NAN], marker="o", facecolor="r", edgecolor="r", s=3)
legend([h], ["scatter"])
savefig("out.png")
close()
The code above fails with ValueError exception:
Traceback (most recent call last):
File "legend.py", line 9, in <module>
legend([h], ["scatter"])
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/pyplot.py",
line 3381, in legend
ret = gca().legend(*args, **kwargs)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axes.py",
line 4778, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend.py",
line 366, in __init__
self._init_legend_box(handles, labels)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend.py",
line 630, in _init_legend_box
handlebox)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend_handler.py",
line 103, in __call__
handlebox.get_transform())
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend_handler.py",
line 325, in create_artists
width, height, fontsize)
File
"/usr/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/legend_handler.py",
line 282, in get_sizes
size_max = max(orig_handle.get_sizes()) * legend.markerscale ** 2
ValueError: max() arg is an empty sequence
There is some more information and the source of the problem described here:
http://stackoverflow.com/questions/29743696/legends-for-scatter-plots-with-nans-in-matplotlib
Thanks,
Tomasz
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Problem-creating-legend-for-scatter-plot-with-NANs-tp45419.html
Sent from the matplotlib - users mailing list archive at Nabble.com.