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