Skip to content

Commit

Permalink
Fix edgecolor in catplot with kind='bar' (#3547)
Browse files Browse the repository at this point in the history
* Fix edgecolor in catplot with kind='bar'

Fixes #3542

* Use rule-based default edgecolor closer to where it is defined
  • Loading branch information
mwaskom authored Nov 4, 2023
1 parent 863539d commit acbb9cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions seaborn/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,11 @@ def catplot(
if saturation < 1:
color = desaturate(color, saturation)

edgecolor = p._complement_color(kwargs.pop("edgecolor", default), color, p._hue_map)
if kind in ["strip", "swarm"]:
kwargs = _normalize_kwargs(kwargs, mpl.collections.PathCollection)
kwargs["edgecolor"] = p._complement_color(
kwargs.pop("edgecolor", default), color, p._hue_map
)

width = kwargs.pop("width", 0.8)
dodge = kwargs.pop("dodge", False if kind in undodged_kinds else "auto")
Expand All @@ -2841,7 +2845,6 @@ def catplot(

jitter = kwargs.pop("jitter", True)
plot_kws = kwargs.copy()
plot_kws["edgecolor"] = edgecolor
plot_kws.setdefault("zorder", 3)
plot_kws.setdefault("linewidth", 0)
if "s" not in plot_kws:
Expand All @@ -2858,7 +2861,6 @@ def catplot(

warn_thresh = kwargs.pop("warn_thresh", .05)
plot_kws = kwargs.copy()
plot_kws["edgecolor"] = edgecolor
plot_kws.setdefault("zorder", 3)
if "s" not in plot_kws:
plot_kws["s"] = plot_kws.pop("size", 5) ** 2
Expand Down
2 changes: 1 addition & 1 deletion tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,7 @@ def test_err_kws(self, fill):
dict(data="long", x="a", y="y", errorbar=("pi", 50)),
dict(data="long", x="a", y="y", errorbar=None),
dict(data="long", x="a", y="y", capsize=.3, err_kws=dict(c="k")),
dict(data="long", x="a", y="y", color="blue", ec="green", alpha=.5),
dict(data="long", x="a", y="y", color="blue", edgecolor="green", alpha=.5),
]
)
def test_vs_catplot(self, long_df, wide_df, null_df, flat_series, kwargs):
Expand Down

0 comments on commit acbb9cf

Please sign in to comment.