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

Document the legend argument of categorical scatterplots #2933

Merged
merged 5 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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: 1 addition & 1 deletion doc/_docstrings/stripplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"metadata": {},
"outputs": [],
"source": [
"sns.stripplot(data=tips, x=\"total_bill\", y=\"day\", hue=\"day\")"
"sns.stripplot(data=tips, x=\"total_bill\", y=\"day\", hue=\"day\", legend=False)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/_docstrings/swarmplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"metadata": {},
"outputs": [],
"source": [
"sns.swarmplot(data=tips, x=\"total_bill\", y=\"day\", hue=\"day\")"
"sns.swarmplot(data=tips, x=\"total_bill\", y=\"day\", hue=\"day\", legend=False)"
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions examples/jitter_stripplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

# Show each observation with a scatterplot
sns.stripplot(x="value", y="measurement", hue="species",
data=iris, dodge=True, alpha=.25, zorder=1)
data=iris, dodge=True, alpha=.25, zorder=1,
legend=False)

# Show the conditional means, aligning each pointplot in the
# center of the strips by adjusting the width allotted to each
Expand All @@ -30,7 +31,6 @@
markers="d", scale=.75, ci=None)

# Improve the legend
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles[3:], labels[3:], title="species",
handletextpad=0, columnspacing=1,
loc="lower right", ncol=3, frameon=True)
sns.move_legend(
ax, loc="lower right", ncol=3, frameon=True, columnspacing=1, handletextpad=0
)
8 changes: 7 additions & 1 deletion seaborn/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,10 @@ def plot(self, ax, boxplot_kws):
Function for converting categorical data into strings. Affects both grouping
and tick labels.\
"""),
legend=dedent("""\
legend : str or bool, optional
If `False` or an empty string and `hue` is used, don't draw a legend.
mwaskom marked this conversation as resolved.
Show resolved Hide resolved
"""),
ax_in=dedent("""\
ax : matplotlib Axes, optional
Axes object to draw the plot onto, otherwise uses the current Axes.\
Expand Down Expand Up @@ -2542,6 +2546,7 @@ def stripplot(
{linewidth}
{native_scale}
{formatter}
{legend}
{ax_in}
kwargs : key, value mappings
Other keyword arguments are passed through to
Expand Down Expand Up @@ -2663,6 +2668,7 @@ def swarmplot(
{linewidth}
{native_scale}
{formatter}
{legend}
{ax_in}
kwargs : key, value mappings
Other keyword arguments are passed through to
Expand Down Expand Up @@ -3272,7 +3278,7 @@ def catplot(
{color}
{palette}
{hue_norm}
legend : bool, optional
legend : str or bool, optional
If ``True`` and there is a ``hue`` variable, draw a legend on the plot.
mwaskom marked this conversation as resolved.
Show resolved Hide resolved
{legend_out}
{share_xy}
Expand Down