Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PairGrid with hue passed in map method #2847

Merged
merged 1 commit into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/releases/v0.12.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Other updates

- |Fix| Fixed a bug in :func:`violinplot` where inner boxes/points could be missing with unpaired split violins (:pr:`2814`).

- |Fix| Fixed a bug in :class:`PairGrid` where and error would be raised when defining `hue` only in the mapping methods (:pr:`2847`).

- |Fix| Subplot titles will no longer be reset when calling :meth:`FacetGrid.map` or :meth:`FacetGrid.map_dataframe` (:pr:`2705`).

- |Fix| In :func:`lineplot`, allowed the `dashes` keyword to set the style of a line without mapping a `style` variable (:pr:`2449`).
Expand Down
7 changes: 4 additions & 3 deletions seaborn/axisgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,9 +1565,10 @@ def _plot_bivariate(self, x_var, y_var, ax, func, **kwargs):
else:
hue = data.get(self._hue_var)

kwargs.setdefault("hue", hue)
kwargs.setdefault("hue_order", self._hue_order)
kwargs.setdefault("palette", self._orig_palette)
if "hue" not in kwargs:
kwargs.update({
"hue": hue, "hue_order": self._hue_order, "palette": self._orig_palette,
})
func(x=x, y=y, **kwargs)

self._update_legend_data(ax)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_axisgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,14 @@ def test_hue_order_missing_level(self):

plt.close("all")

def test_hue_in_map(self, long_df):

g = ag.PairGrid(long_df, vars=["x", "y"])
g.map(scatterplot, hue=long_df["a"])
ax = g.axes.flat[0]
points = ax.collections[0]
assert len(set(map(tuple, points.get_facecolors()))) == 3

def test_nondefault_index(self):

df = self.df.copy().set_index("b")
Expand Down