-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone
Description
The 3.0.x series added new checks in scatter
for equivalence between the length of the x
, y
vectors and the length of the c
vectors.
These changes have broken code in seaborn that sometimes calls scatter with empty position data but non-empty color data, e.g.
import matplotlib.pyplot as plt
f, 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>()
1 import matplotlib.pyplot as plt
2 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: pretty
ValueError: '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 the c
parameter occupies a fuzzy zone between data and style attribute. But specifically in the case when the position data are empty, no points will have the wrong colors.
Metadata
Metadata
Assignees
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.