I'm on Seaborn 0.9.0.
import seaborn as sns
df = sns.load_dataset("exercise")
# intentionally remove some points
df = df.drop(df.query("kind == 'walking' & time == '1 min'").index)
sns.catplot(x="time", y="pulse", hue="kind", kind='point', data=df)
With Matplotlib 3.0.2:

With Matplotlib 3.1.0:
ValueError Traceback (most recent call last)
<ipython-input-3-0ddfdcca1938> in <module>
1 df = sns.load_dataset("exercise")
2 df = df.drop(df.query("kind == 'walking' & time == '1 min'").index)
----> 3 sns.catplot(x="time", y="pulse", hue="kind", kind='point', data=df)
/usr/local/lib/python3.7/site-packages/seaborn/categorical.py in catplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, order, hue_order, row_order, col_order, kind, height, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
3753
3754 # Draw the plot onto the facets
-> 3755 g.map_dataframe(plot_func, x, y, hue, **plot_kws)
3756
3757 # Special case axis labels for a count type plot
/usr/local/lib/python3.7/site-packages/seaborn/axisgrid.py in map_dataframe(self, func, *args, **kwargs)
818
819 # Draw the plot
--> 820 self._facet_plot(func, ax, args, kwargs)
821
822 # Finalize the annotations and layout
/usr/local/lib/python3.7/site-packages/seaborn/axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)
836
837 # Draw the plot
--> 838 func(*plot_args, **plot_kwargs)
839
840 # Sort out the supporting information
/usr/local/lib/python3.7/site-packages/seaborn/categorical.py in pointplot(x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, markers, linestyles, dodge, join, scale, orient, color, palette, errwidth, capsize, ax, **kwargs)
3338 ax = plt.gca()
3339
-> 3340 plotter.plot(ax)
3341 return ax
3342
/usr/local/lib/python3.7/site-packages/seaborn/categorical.py in plot(self, ax)
1809 def plot(self, ax):
1810 """Make the plot."""
-> 1811 self.draw_points(ax)
1812 self.annotate_axes(ax)
1813 if self.orient == "h":
/usr/local/lib/python3.7/site-packages/seaborn/categorical.py in draw_points(self, ax)
1805 c=point_colors, edgecolor=point_colors,
1806 linewidth=mew, marker=marker, s=markersize,
-> 1807 zorder=z)
1808
1809 def plot(self, ax):
/usr/local/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
1587 def inner(ax, *args, data=None, **kwargs):
1588 if data is None:
-> 1589 return func(ax, *map(sanitize_sequence, args), **kwargs)
1590
1591 bound = new_sig.bind(ax, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, **kwargs)
4488 offsets=offsets,
4489 transOffset=kwargs.pop('transform', self.transData),
-> 4490 alpha=alpha
4491 )
4492 collection.set_transform(mtransforms.IdentityTransform())
/usr/local/lib/python3.7/site-packages/matplotlib/collections.py in __init__(self, paths, sizes, **kwargs)
881 """
882
--> 883 Collection.__init__(self, **kwargs)
884 self.set_paths(paths)
885 self.set_sizes(sizes)
/usr/local/lib/python3.7/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
126 self._hatch_color = mcolors.to_rgba(mpl.rcParams['hatch.color'])
127 self.set_facecolor(facecolors)
--> 128 self.set_edgecolor(edgecolors)
129 self.set_linewidth(linewidths)
130 self.set_linestyle(linestyles)
/usr/local/lib/python3.7/site-packages/matplotlib/collections.py in set_edgecolor(self, c)
726 """
727 self._original_edgecolor = c
--> 728 self._set_edgecolor(c)
729
730 def set_alpha(self, alpha):
/usr/local/lib/python3.7/site-packages/matplotlib/collections.py in _set_edgecolor(self, c)
710 except AttributeError:
711 pass
--> 712 self._edgecolors = mcolors.to_rgba_array(c, self._alpha)
713 if set_hatch_color and len(self._edgecolors):
714 self._hatch_color = tuple(self._edgecolors[0])
/usr/local/lib/python3.7/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
284 result = np.empty((len(c), 4), float)
285 for i, cc in enumerate(c):
--> 286 result[i] = to_rgba(cc, alpha)
287 return result
288
/usr/local/lib/python3.7/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
175 rgba = None
176 if rgba is None: # Suppress exception chaining of cache lookup failure.
--> 177 rgba = _to_rgba_no_colorcycle(c, alpha)
178 try:
179 _colors_full_map.cache[c, alpha] = rgba
/usr/local/lib/python3.7/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
236 # float)` and `np.array(...).astype(float)` all convert "0.5" to 0.5.
237 # Test dimensionality to reject single floats.
--> 238 raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
239 # Return a tuple to prevent the cached value from being modified.
240 c = tuple(c.astype(float))
ValueError: Invalid RGBA argument: masked
Looks like matplotlib 3.1 is breaking a lot of things. You鈥檒l have to downgrade for the time being, sorry.
the problem is solved in Matplolib master of today, for example by replacing the colors.py file entirely.
I think it's via this comit
https://github.com/matplotlib/matplotlib/commit/04baaf71b3f1242bfbc0dc12dc06c127878e558e
Great, thanks @stonebig.
What's the solution here? Wait for matplotlib to fix itself?
3.1.1 with the relevant bugfix has just been released.
I am still problem in using catplot with poinplot and hue.
Matplotlib 3.1.1
Seaborn 0.9.0
Anaconda Python 3.6.7
The error I got is "ValueError: 'c' argument has 8 elements, which is not acceptable for use with 'x' with size 0, 'y' with size 0."
Please suggest some fix.
Same error here, in a similar situation.
Same error for the above example while using the following configurations:
@dmantadakis it would be more helpful to provide a complete report but I think you're seeing a separate issue that's been reported to matplotlib here: https://github.com/matplotlib/matplotlib/issues/19066
@mwaskom Here is the code
import pandas as pd
import seaborn as sns
df = sns.load_dataset("exercise")
df = df.drop(df.query("kind == 'walking' & time == '1 min'").index)
sns.catplot(x="time", y="pulse", hue="kind", kind='point', data=df)
and here is the Traceback
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-d161056f41d0> in <module>
5 df = sns.load_dataset("exercise")
6 df = df.drop(df.query("kind == 'walking' & time == '1 min'").index)
----> 7 sns.catplot(x="time", y="pulse", hue="kind", kind='point', data=df)
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs)
44 )
45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46 return f(**kwargs)
47 return inner_f
48
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/categorical.py in catplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, seed, order, hue_order, row_order, col_order, kind, height, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
3842
3843 # Draw the plot onto the facets
-> 3844 g.map_dataframe(plot_func, x=x, y=y, hue=hue, **plot_kws)
3845
3846 if p.orient == "h":
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/axisgrid.py in map_dataframe(self, func, *args, **kwargs)
748
749 # Draw the plot
--> 750 self._facet_plot(func, ax, args, kwargs)
751
752 # Finalize the annotations and layout
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)
773 plot_args = []
774 plot_kwargs["ax"] = ax
--> 775 func(*plot_args, **plot_kwargs)
776
777 # Sort out the supporting information
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs)
44 )
45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46 return f(**kwargs)
47 return inner_f
48
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/categorical.py in pointplot(x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, seed, markers, linestyles, dodge, join, scale, orient, color, palette, errwidth, capsize, ax, **kwargs)
3378 ax = plt.gca()
3379
-> 3380 plotter.plot(ax)
3381 return ax
3382
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/categorical.py in plot(self, ax)
1786 def plot(self, ax):
1787 """Make the plot."""
-> 1788 self.draw_points(ax)
1789 self.annotate_axes(ax)
1790 if self.orient == "h":
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/seaborn/categorical.py in draw_points(self, ax)
1779 x = y = [np.nan] * n_points
1780
-> 1781 ax.scatter(x, y, label=hue_level,
1782 facecolor=color, edgecolor=color,
1783 linewidth=mew, marker=marker, s=markersize,
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
1445 def inner(ax, *args, data=None, **kwargs):
1446 if data is None:
-> 1447 return func(ax, *map(sanitize_sequence, args), **kwargs)
1448
1449 bound = new_sig.bind(ax, *args, **kwargs)
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py in wrapper(*inner_args, **inner_kwargs)
409 else deprecation_addendum,
410 **kwargs)
--> 411 return func(*inner_args, **inner_kwargs)
412
413 return wrapper
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, **kwargs)
4486 offsets = np.ma.column_stack([x, y])
4487
-> 4488 collection = mcoll.PathCollection(
4489 (path,), scales,
4490 facecolors=colors,
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/collections.py in __init__(self, paths, sizes, **kwargs)
951 """
952
--> 953 super().__init__(**kwargs)
954 self.set_paths(paths)
955 self.set_sizes(sizes)
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py in wrapper(*inner_args, **inner_kwargs)
409 else deprecation_addendum,
410 **kwargs)
--> 411 return func(*inner_args, **inner_kwargs)
412
413 return wrapper
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
173 self._hatch_color = mcolors.to_rgba(mpl.rcParams['hatch.color'])
174 self.set_facecolor(facecolors)
--> 175 self.set_edgecolor(edgecolors)
176 self.set_linewidth(linewidths)
177 self.set_linestyle(linestyles)
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/collections.py in set_edgecolor(self, c)
828 """
829 self._original_edgecolor = c
--> 830 self._set_edgecolor(c)
831
832 def set_alpha(self, alpha):
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/collections.py in _set_edgecolor(self, c)
812 except AttributeError:
813 pass
--> 814 self._edgecolors = mcolors.to_rgba_array(c, self._alpha)
815 if set_hatch_color and len(self._edgecolors):
816 self._hatch_color = tuple(self._edgecolors[0])
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
339 return np.zeros((0, 4), float)
340 else:
--> 341 return np.array([to_rgba(cc, alpha) for cc in c])
342
343
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/colors.py in <listcomp>(.0)
339 return np.zeros((0, 4), float)
340 else:
--> 341 return np.array([to_rgba(cc, alpha) for cc in c])
342
343
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
187 rgba = None
188 if rgba is None: # Suppress exception chaining of cache lookup failure.
--> 189 rgba = _to_rgba_no_colorcycle(c, alpha)
190 try:
191 _colors_full_map.cache[c, alpha] = rgba
~/Sources/python_virtual_environments/.gslab_generic/lib/python3.8/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
261 # tuple color.
262 if not np.iterable(c):
--> 263 raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
264 if len(c) not in [3, 4]:
265 raise ValueError("RGBA sequence should have length 3 or 4")
ValueError: Invalid RGBA argument: 0.4980392156862745
Most helpful comment
3.1.1 with the relevant bugfix has just been released.