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

Add the concept of a "layer legend" to so.Plot #3456

Merged
merged 5 commits into from
Aug 31, 2023
Merged

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Aug 31, 2023

This introduces an alternate way to provide information about what different marks or mark properties mean. It is similar to how label= is used when passed to a specific matplotlib artist.

For example, you can use it to gloss marks that represent different kinds of values:

(
    so.Plot(tips, x="total_bill", y="tip")
    .add(so.Dots(), label="Data")
    .add(so.Line(), so.PolyFit(), label="Model")
)

It is also useful for plotting multiple variables in cases where it would be awkward to reshape the data source to long-form:

(
    so.Plot(tips, x="size")
    .add(so.Dots(color="C1"), so.Jitter(), y="total_bill", label="Bill")
    .add(so.Dots(color="C2"), so.Jitter(), y="tip", label="Tip")
    .label(legend="Source")
)

Closes #3046

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #3456 (f9aa345) into master (0a64c1a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3456   +/-   ##
=======================================
  Coverage   98.32%   98.33%           
=======================================
  Files          75       75           
  Lines       24408    24438   +30     
=======================================
+ Hits        24000    24030   +30     
  Misses        408      408           
Files Changed Coverage Δ
seaborn/_marks/base.py 98.48% <ø> (ø)
seaborn/_core/plot.py 98.29% <100.00%> (+0.02%) ⬆️
tests/_core/test_plot.py 98.82% <100.00%> (+0.01%) ⬆️

@mwaskom mwaskom merged commit 082486d into master Aug 31, 2023
12 checks passed
@mwaskom mwaskom deleted the plot/layer_legend branch August 31, 2023 12:54
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.

Support "layer labels" with legend
1 participant