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 Est stat and Interval mark to show error bars #2912

Merged
merged 9 commits into from
Jul 24, 2022
Merged

Add Est stat and Interval mark to show error bars #2912

merged 9 commits into from
Jul 24, 2022

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Jul 18, 2022

This PR adds a new mark and a new stat that together will add error bars to aggregations:

(
    so.Plot(diamonds, x="carat", y="clarity")
    .add(so.Interval(), so.Est("mean", "sd"))
    .add(so.Dot(), so.Agg())
)

image

The Est stay has the same basic API for error bar selection as we'll be rolling out for the functional interface in 0.12 (i.e., ci/se/pi/sd, with an optional scale/level parameter.

Note that is currently necessary to add two layers to get a dot + interval; see #2911 for some ideas there

This PR also addresses some wrinkles relating to matplotlib capstyles in both the interval mark and existing line marks.

@mwaskom
Copy link
Owner Author

mwaskom commented Jul 18, 2022

Here's something that needs to be addressed:

(
    so.Plot(penguins, x="bill_length_mm", y="species", color="sex")
    .add(so.Interval(), so.Est(), so.Dodge())
    .add(so.Dot(), so.Agg(), so.Dodge())
)

image

This is because Interval and Dot end up with different grouping_props; it can be worked around:

(
    so.Plot(penguins, x="bill_length_mm", y="species", color="sex")
    .add(so.Interval(), so.Est(), so.Dodge(by=["color"]))
    .add(so.Dot(), so.Agg(), so.Dodge())
)

image

But this needs a cleaner solution (cf #2894)

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #2912 (edb5c3c) into master (b726628) will increase coverage by 0.01%.
The diff coverage is 99.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2912      +/-   ##
==========================================
+ Coverage   98.20%   98.22%   +0.01%     
==========================================
  Files          69       69              
  Lines       22666    22822     +156     
==========================================
+ Hits        22260    22416     +156     
  Misses        406      406              
Impacted Files Coverage Δ
seaborn/_stats/histograms.py 98.82% <ø> (ø)
seaborn/_core/scales.py 89.36% <75.00%> (-0.17%) ⬇️
seaborn/_core/plot.py 94.97% <100.00%> (+0.02%) ⬆️
seaborn/_marks/bars.py 100.00% <100.00%> (ø)
seaborn/_marks/lines.py 100.00% <100.00%> (ø)
seaborn/_stats/aggregation.py 97.50% <100.00%> (+5.50%) ⬆️
seaborn/objects.py 100.00% <100.00%> (ø)
tests/_marks/test_lines.py 100.00% <100.00%> (ø)
tests/_stats/test_aggregation.py 100.00% <100.00%> (ø)

@mwaskom mwaskom merged commit fb61ded into master Jul 24, 2022
@mwaskom mwaskom deleted the errorbars branch July 24, 2022 22:25
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