Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
The 3.0.x series added new checks inscatter
for equivalence between the length of thex
,y
vectors and the length of thec
vectors.
These changes have broken code in seaborn that sometimes calls scatter with empty position data but non-empty color data, e.g.
importmatplotlib.pyplotaspltf,ax=plt.subplots()ax.scatter([], [],c=["r","b","g"])
---------------------------------------------------------------------------ValueError Traceback (most recent call last)~/anaconda/envs/seaborn-dev/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs) 4237 valid_shape = False-> 4238 raise ValueError 4239 except ValueError:ValueError: During handling of the above exception, another exception occurred:ValueError Traceback (most recent call last)<ipython-input-2-41dfae030a6e> in <module>()1import matplotlib.pyplotas plt2 f, ax= plt.subplots()----> 3 ax.scatter([], [], c=["r", "b", "g"])~/anaconda/envs/seaborn-dev/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs) 1808 "the Matplotlib list!)" % (label_namer, func.__name__), 1809 RuntimeWarning, stacklevel=2)-> 1810 return func(ax, *args, **kwargs) 1811 1812 inner.__doc__ = _add_data_doc(inner.__doc__,~/anaconda/envs/seaborn-dev/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs) 4243 "acceptable for use with 'x' with size {xs}, " 4244 "'y' with size {ys}."-> 4245 .format(nc=n_elem, xs=x.size, ys=y.size) 4246 ) 4247 # Both the mapping *and* the RGBA conversion failed: prettyValueError:'c' argument has 3 elements, which is not acceptable for use with 'x' with size 0, 'y' with size 0.
IMO this is an unnecessary exception because it conflicts with another patten in matplotlib, which is passing empty data along with specified style attributes (e.g. to create a proxy artist). I appreciate that thec
parameter occupies a fuzzy zone between data and style attribute. But specifically in the case when the position data areempty, no points will have the wrong colors.