From 52b291c793e500762d4822d6b8f8b212937d0080 Mon Sep 17 00:00:00 2001 From: aydinomer00 <109145643+aydinomer00@users.noreply.github.com> Date: Sat, 28 Dec 2024 14:35:24 +0300 Subject: [PATCH] Fix capitalization for countplot stat label and add test --- seaborn/categorical.py | 2 +- tests/test_categorical.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/seaborn/categorical.py b/seaborn/categorical.py index ee8aa0908b..6a46a17a40 100644 --- a/seaborn/categorical.py +++ b/seaborn/categorical.py @@ -2669,7 +2669,7 @@ def countplot( p.plot_data[count_axis] = 1 _check_argument("stat", ["count", "percent", "probability", "proportion"], stat) - p.variables[count_axis] = stat + p.variables[count_axis] = stat.capitalize() if stat != "count": denom = 100 if stat == "percent" else 1 p.plot_data[count_axis] /= len(p.plot_data) / denom diff --git a/tests/test_categorical.py b/tests/test_categorical.py index 3df7824787..12c5521ae8 100644 --- a/tests/test_categorical.py +++ b/tests/test_categorical.py @@ -3259,3 +3259,14 @@ def test_children(self, container): children = container.get_children() for child in children: assert isinstance(child, mpl.artist.Artist) + + +def test_countplot_stat_label_capitalization(): + import seaborn as sns + import matplotlib.pyplot as plt + + data = sns.load_dataset("iris") + ax = sns.countplot(data=data, x="sepal_width", stat="count") + + assert ax.get_ylabel() == "Count" + plt.close() # Cleanup