mwaskom / seaborn

Statistical data visualization in Python

Home Page:https://seaborn.pydata.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introducing `seaborn_objects_recipes` Library

Ofosu-Osei opened this issue · comments

I am excited to introduce a new library we've (@nickeubank) been working on, seaborn_objects_recipes. This library extends seaborn.objects by providing additional functionalities that we hope will be useful for your data visualization needs.

Features
The library includes the following recipes:

  • Rolling: Apply rolling window calculations to your data.
  • LineLabel: Add labels directly to your lines for better readability.
  • Lowess: Perform locally-weighted regression smoothing, with support for confidence intervals.
  • PolyFitWithCI: Fit polynomial regression models and include confidence intervals.

Example Usage
Here's a quick example using the PolyFitWithCI recipes:

import seaborn.objects as so
import seaborn as sns
import seaborn_objects_recipes as sor
    
    # Load the penguins dataset
    penguins = sns.load_dataset("penguins")

    # Prepare data
    data = penguins.copy()
    data = data[data["species"] == "Adelie"]

    # Create the plot
    plot = (
        so.Plot(data, x="bill_length_mm", y="body_mass_g")
        .add(so.Dot())
        .add(so.Line(), PolyFitWithCI := sor.PolyFitWithCI(order=2, gridsize=100, alpha=0.05))
        .add(so.Band(), PolyFitWithCI)
        .label(x="Bill Length (mm)", y="Body Mass (g)", title="PolyFit Plot with Confidence Intervals")
    )
    # Display Plot
    plot.show()

Output

polyfit_with_ci

Acknowledgements
We'd like to acknowledge and thank the following contributors from whom we've borrowed code:

Feedback Request
We are looking for feedback on the following:

  1. Integration: Should this library remain a separate extension, or would it be better to roll these features directly into seaborn.objects?
  2. Confidence Intervals: We are particularly interested in feedback on how we're handling confidence intervals in our Lowess and PolyFitWithCI implementations.

You can find the library and more examples on our GitHub repository: seaborn_objects_recipes.

Looking forward to your feedback!

Sounds nice ! I have some objects I can contribute if you'd like.

Sounds nice ! I have some objects I can contribute if you'd like.

Please do! Pulling together all the stuff I think people have been making in their own is precisely the goal!