-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Milestone
Description
This simple plot raises:
so.Plot([0, 0], [1, 2]).add(so.Dot())Traceback
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/miniconda/envs/py310/lib/python3.10/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 method = get_real_method(obj, self.print_method)
342 if method is not None:
--> 343 return method()
344 return None
345 else:
File ~/code/seaborn/seaborn/_core/plot.py:278, in Plot._repr_png_(self)
276 def _repr_png_(self) -> tuple[bytes, dict[str, float]]:
--> 278 return self.plot()._repr_png_()
File ~/code/seaborn/seaborn/_core/plot.py:820, in Plot.plot(self, pyplot)
816 """
817 Compile the plot spec and return the Plotter object.
818 """
819 with theme_context(self._theme_with_defaults()):
--> 820 return self._plot(pyplot)
File ~/code/seaborn/seaborn/_core/plot.py:850, in Plot._plot(self, pyplot)
848 # Process the data for each layer and add matplotlib artists
849 for layer in layers:
--> 850 plotter._plot_layer(self, layer)
852 # Add various figure decorations
853 plotter._make_legend(self)
File ~/code/seaborn/seaborn/_core/plot.py:1351, in Plotter._plot_layer(self, p, layer)
1348 grouping_vars = mark._grouping_props + default_grouping_vars
1349 split_generator = self._setup_split_generator(grouping_vars, df, subplots)
-> 1351 mark._plot(split_generator, scales, orient)
1353 # TODO is this the right place for this?
1354 for view in self._subplots:
File ~/code/seaborn/seaborn/_marks/dot.py:71, in DotBase._plot(self, split_gen, scales, orient)
68 for _, data, ax in split_gen():
70 offsets = np.column_stack([data["x"], data["y"]])
---> 71 data = self._resolve_properties(data, scales)
73 points = mpl.collections.PathCollection(
74 offsets=offsets,
75 paths=data["path"],
(...)
83 **self.artist_kws,
84 )
85 ax.add_collection(points)
File ~/code/seaborn/seaborn/_marks/dot.py:141, in Dot._resolve_properties(self, data, scales)
138 edge_stroke = resolved["edgewidth"]
139 resolved["linewidth"] = np.where(filled, edge_stroke, main_stroke)
--> 141 main_color = resolve_color(self, data, "", scales)
142 edge_color = resolve_color(self, data, "edge", scales)
144 if not np.isscalar(filled):
145 # Expand dims to use in np.where with rgba arrays
File ~/code/seaborn/seaborn/_marks/base.py:279, in resolve_color(mark, data, prefix, scales)
277 return mpl.colors.to_rgba(color)
278 alpha = alpha if visible(color) else np.nan
--> 279 return mpl.colors.to_rgba(color, alpha)
280 else:
281 if np.ndim(color) == 2 and color.shape[1] == 4:
File ~/miniconda/envs/py310/lib/python3.10/site-packages/matplotlib/colors.py:299, in to_rgba(c, alpha)
297 rgba = None
298 if rgba is None: # Suppress exception chaining of cache lookup failure.
--> 299 rgba = _to_rgba_no_colorcycle(c, alpha)
300 try:
301 _colors_full_map.cache[c, alpha] = rgba
File ~/miniconda/envs/py310/lib/python3.10/site-packages/matplotlib/colors.py:383, in _to_rgba_no_colorcycle(c, alpha)
381 raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
382 if len(c) not in [3, 4]:
--> 383 raise ValueError("RGBA sequence should have length 3 or 4")
384 if not all(isinstance(x, Number) for x in c):
385 # Checks that don't work: `map(float, ...)`, `np.array(..., float)` and
386 # `np.array(...).astype(float)` would all convert "0.5" to 0.5.
387 raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
ValueError: RGBA sequence should have length 3 or 4But the issue isn't about color mapping, it's because the data is empty, if you drop into the debugger and go up 4 levels you get
print(data)
Empty DataFrame
Columns: [x, y, width, baseline]
Index: []