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

Improve legend for categorical scatterplots #2828

Merged
merged 7 commits into from
Jun 2, 2022
Merged

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Jun 1, 2022

This ties up some loose ends from #2413 and #2447, which allowed them to apply a continuous mapping to the hue variable without upgrading the legend machinery to properly show a colorbar-like legend. Now that works as expected:

sns.catplot(diamonds, x="cut", y="price", hue="carat", jitter=.4, s=5)

image

The solution is a bit of a shortcut, simply making _CategoricalPlotterNew subclass _RelationalPlotter, where the relevant method for creating legend artists lives. Probably that method should be moved down to the base class level to keep a cleaner division between the modules (but also, the distributions module has a different approach altogether). Legends remain a mess.

@mwaskom mwaskom added this to the v0.12.0 milestone Jun 1, 2022
@codecov
Copy link

codecov bot commented Jun 1, 2022

Codecov Report

Merging #2828 (d2913f2) into master (fefd940) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2828   +/-   ##
=======================================
  Coverage   98.04%   98.05%           
=======================================
  Files          68       68           
  Lines       21991    22014   +23     
=======================================
+ Hits        21561    21585   +24     
+ Misses        430      429    -1     
Impacted Files Coverage Δ
seaborn/relational.py 99.69% <ø> (ø)
seaborn/categorical.py 98.32% <100.00%> (+0.08%) ⬆️
seaborn/tests/test_categorical.py 99.77% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fefd940...d2913f2. Read the comment docs.

@mwaskom mwaskom merged commit dce3150 into master Jun 2, 2022
@mwaskom mwaskom deleted the cat/scatter_legend branch June 2, 2022 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant