diff --git a/seaborn/categorical.py b/seaborn/categorical.py index 80c2478d4f..cdb2b3e5ac 100644 --- a/seaborn/categorical.py +++ b/seaborn/categorical.py @@ -409,12 +409,10 @@ def _invert_scale(self, ax, data, vars=("x", "y")): data[col] = inv(data[col]) def _configure_legend(self, ax, func, common_kws=None, semantic_kws=None): - if self.legend == "auto": show_legend = not self._redundant_hue and self.input_format != "wide" else: show_legend = bool(self.legend) - if show_legend: self.add_legend_data(ax, func, common_kws, semantic_kws=semantic_kws) handles, _ = ax.get_legend_handles_labels() @@ -3095,21 +3093,12 @@ def catplot( g._update_legend_data(ax) ax.legend_ = None - if legend and "hue" in p.variables and p.input_format == "long": - # Obtaining the column names for hue, x, and y. - hue_value = p.variables.get("hue") - x_value = p.variables.get("x") - y_value = p.variables.get("y") - # Obtaining the datatype of hue - hue_type = p.var_types.get("hue") - if legend == 'auto' and hue_value in {x_value, y_value} \ - and hue_type != 'numeric': - # Setting the title of hue to None if hue matches "x" or - # "y", or if the data type of "hue" is numeric. - title_hue = None - else: - title_hue = hue_value - g.add_legend(title=title_hue, label_order=hue_order) + if legend == "auto": + show_legend = not p._redundant_hue and p.input_format != "wide" + else: + show_legend = bool(legend) + if show_legend: + g.add_legend(title=p.variables.get("hue"), label_order=hue_order) if data is not None: # Replace the dataframe on the FacetGrid for any subsequent maps