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

[BUG] Edge color with catplot with kind=bar #3542

Closed
prabhuteja12 opened this issue Oct 27, 2023 · 5 comments · Fixed by #3547
Closed

[BUG] Edge color with catplot with kind=bar #3542

prabhuteja12 opened this issue Oct 27, 2023 · 5 comments · Fixed by #3547

Comments

@prabhuteja12
Copy link

Hello,

When passing edgecolor to catplot for a bar, the argument doesn't reach the underlying p.plot_bars to generate the required output.

Currently there is a line
edgecolor = p._complement_color(kwargs.pop("edgecolor", default), color, p._hue_map)

is not passed into the block elif kind=="bar". A local "hack" I implemented is to add a kwargs["edgecolor"] = edgecolor before p.plot_bars call. Let me know if I should provide more details.

This is on version 0.13.0.

@mwaskom
Copy link
Owner

mwaskom commented Oct 27, 2023

Can you provide a full reproducible example using one of the sample datasets? Thanks!

@mwaskom mwaskom added this to the v0.13.1 milestone Oct 28, 2023
@prabhuteja12
Copy link
Author

The default example shows this:

df = sns.load_dataset("titanic")
g = sns.catplot(
       data=df, x="who", y="survived", col="class",
        kind="bar", height=4, aspect=.6, edgecolor="r")
g.set_axis_labels("", "Survival  Rate")
g.set_xticklabels(["Men", "Women", "Children"])
g.set_titles("{col_name} {col_var}")
g.set(ylim=(0, 1))
g.despine(left=True)

The output is
image

I see that this works as intended in 0.12.2 but not in 0.13.0.

@mwaskom
Copy link
Owner

mwaskom commented Nov 1, 2023

Thanks, let's simplify even further...

df = sns.load_dataset("titanic")
sns.catplot(data=df, x="who", y="survived", kind="bar", edgecolor="r")

@mwaskom
Copy link
Owner

mwaskom commented Nov 2, 2023

Interestingly this works with the short-form parameter (which is why it passes the test that checks it):

sns.catplot(data=df, x="who", y="survived", kind="bar", ec="r")

mwaskom added a commit that referenced this issue Nov 4, 2023
mwaskom added a commit that referenced this issue Nov 4, 2023
* Fix edgecolor in catplot with kind='bar'

Fixes #3542

* Use rule-based default edgecolor closer to where it is defined
@prabhuteja12
Copy link
Author

Awesome! Thank you for fixing it!

mwaskom added a commit that referenced this issue Nov 4, 2023
* Fix edgecolor in catplot with kind='bar'

Fixes #3542

* Use rule-based default edgecolor closer to where it is defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants