tpvasconcelos / ridgeplot

Beautiful ridgeline plots in Python
https://ridgeplot.readthedocs.io/
MIT License
65 stars 3 forks source link

Implement functionality to plot multiple traces per row #114

Closed tpvasconcelos closed 1 year ago

tpvasconcelos commented 1 year ago

solves #77

Example plot with multiple traces per row:

image

Sample code:

import numpy as np
from ridgeplot import ridgeplot
from ridgeplot.datasets import load_lincoln_weather

# Load test data
df = load_lincoln_weather()

# Transform the data into a 3D (ragged) array format of
# daily min and max temperature samples per month
months = df.index.month_name().unique()
samples = [
    [
        df[df.index.month_name() == month]["Min Temperature [F]"],
        df[df.index.month_name() == month]["Max Temperature [F]"],
    ]
    for month in months
]

# And finish by styling it up to your liking!
fig = ridgeplot(
    samples=samples,
    labels=months,
    coloralpha=0.98,
    bandwidth=4,
    kde_points=np.linspace(-25, 110, 400),
    spacing=0.33,
    linewidth=2,
)
fig.update_layout(
    title="Minimum and maximum daily temperatures in Lincoln, NE (2016)",
    height=650,
    width=950,
    font_size=14,
    plot_bgcolor="rgb(245, 245, 245)",
    xaxis_gridcolor="white",
    yaxis_gridcolor="white",
    xaxis_gridwidth=2,
    yaxis_title="Month",
    xaxis_title="Temperature [F]",
    showlegend=False,
)
fig.show()
codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 58.56% and project coverage change: -2.69% :warning:

Comparison is base (4843011) 65.63% compared to head (197a67f) 62.95%. Report is 1 commits behind head on main.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #114 +/- ## ========================================== - Coverage 65.63% 62.95% -2.69% ========================================== Files 11 11 Lines 259 386 +127 Branches 43 65 +22 ========================================== + Hits 170 243 +73 - Misses 89 140 +51 - Partials 0 3 +3 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `62.95% <58.56%> (-2.69%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos) | Coverage Δ | | |---|---|---| | [src/ridgeplot/\_ridgeplot.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fcmlkZ2VwbG90LnB5) | `27.77% <29.16%> (-11.12%)` | :arrow_down: | | [src/ridgeplot/\_figure\_factory.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fZmlndXJlX2ZhY3RvcnkucHk=) | `32.81% <36.55%> (+9.64%)` | :arrow_up: | | [src/ridgeplot/\_utils.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fdXRpbHMucHk=) | `71.11% <40.90%> (-28.89%)` | :arrow_down: | | [src/ridgeplot/datasets/\_\_init\_\_.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9kYXRhc2V0cy9fX2luaXRfXy5weQ==) | `70.58% <69.23%> (-29.42%)` | :arrow_down: | | [src/ridgeplot/\_kde.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fa2RlLnB5) | `75.00% <70.83%> (+41.66%)` | :arrow_up: | | [src/ridgeplot/\_colors.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fY29sb3JzLnB5) | `96.61% <86.66%> (-3.39%)` | :arrow_down: | | [src/ridgeplot/\_testing.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fdGVzdGluZy5weQ==) | `88.88% <87.50%> (-11.12%)` | :arrow_down: | | [src/ridgeplot/\_types.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fdHlwZXMucHk=) | `98.18% <98.03%> (+3.18%)` | :arrow_up: | | [src/ridgeplot/\_\_init\_\_.py](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#diff-c3JjL3JpZGdlcGxvdC9fX2luaXRfXy5weQ==) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.