-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Milestone
Description
MWE
df1 = pd.DataFrame({}, columns=["aa", "bb", "cc"]) # empty dataframe
# df1 = pd.DataFrame([(1, 2, 3), (2, 1, 3)], columns=["aa", "bb", "cc"]) # with this, it works
sns.lineplot(df1, x="aa", y="bb") # works
sns.lineplot(df1, x="aa", y="bb", hue="cc") # does not work
Error happens with seaborn 0.13.0, but not with 0.12.2:
Error:
File .../python3.10/site-packages/seaborn/relational.py:507, in lineplot(data, x, y, hue, size, style, units, palette, hue_order, hue_norm, sizes, size_order, size_norm, dashes, markers, style_order, estimator, errorbar, n_boot, seed, orient, sort, err_style, err_kws, legend, ci, ax, **kwargs)
504 color = kwargs.pop("color", kwargs.pop("c", None))
505 kwargs["color"] = _default_color(ax.plot, hue, color, kwargs)
--> 507 p.plot(ax, kwargs)
508 return ax
File .../python3.10/site-packages/seaborn/relational.py:274, in _LinePlotter.plot(self, ax, kws)
266 # TODO How to handle NA? We don't want NA to propagate through to the
267 # estimate/CI when some values are present, but we would also like
268 # matplotlib to show "gaps" in the line when all values are missing.
(...)
271
272 # Loop over the semantic subsets and add to the plot
273 grouping_vars = "hue", "size", "style"
--> 274 for sub_vars, sub_data in self.iter_data(grouping_vars, from_comp_data=True):
276 if self.sort:
277 sort_vars = ["units", orient, other]
File .../python3.10/site-packages/seaborn/_base.py:938, in VectorPlotter.iter_data(self, grouping_vars, reverse, from_comp_data, by_facet, allow_empty, dropna)
935 for var in grouping_vars:
936 grouping_keys.append(levels.get(var, []))
--> 938 iter_keys = itertools.product(*grouping_keys)
939 if reverse:
940 iter_keys = reversed(list(iter_keys))
TypeError: 'NoneType' object is not iterable