Skip to content

Commit

Permalink
Merge pull request #299 from mwaskom/fix_lmplot_legend
Browse files Browse the repository at this point in the history
Don't show lmplot legend when hue in [row, col]
  • Loading branch information
mwaskom committed Sep 21, 2014
2 parents ecdf9ef + bebfa76 commit 34957a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/releases/v0.5.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Color palettes
Bug fixes
~~~~~~~~~

- Fixed a bug where :func:`lmplot` would show a legend when the hue variable was also used on either the rows or columns (making the legend redundant).

- Fixed a bug in :class:`PairGrid` that gave incorrect results (or a crash) when the input DataFrame has a non-default index.

- Fixed a bug in :class:`PairGrid` where passing columns with a date-like datatype raised an exception.
Expand Down
2 changes: 1 addition & 1 deletion seaborn/linearmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def lmplot(x, y, data, hue=None, col=None, row=None, palette=None,
facets.map_dataframe(regplot, x, y, **kwargs)

# Add a legend
if hue is not None and legend:
if legend and (hue is not None) and (hue not in [col, row]):
facets.add_legend()
return facets

Expand Down
5 changes: 5 additions & 0 deletions seaborn/tests/test_linearmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,11 @@ def test_lmplot_facets(self):

plt.close("all")

def test_lmplot_hue_col_nolegend(self):

g = lm.lmplot("x", "y", data=self.df, col="h", hue="h")
nt.assert_is(g._legend, None)

def test_lmplot_scatter_kws(self):

g = lm.lmplot("x", "y", hue="h", data=self.df, ci=None)
Expand Down

0 comments on commit 34957a5

Please sign in to comment.