has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
3.92k stars 210 forks source link

No upper outline in `geom_ribbon()` #728

Closed MathisC22 closed 6 months ago

MathisC22 commented 8 months ago

When adding prediction intervals to my plot via geom_ribbon(), I noticed that geom_ribbon() does not add an outline to the upper end of the shaded area when setting either outline_type="both" or outline_type="upper". It works, however, when setting outline_type="full".

Reproducible example:

from plotnine import * 
import polars as pl 

df = pl.DataFrame({
    "x": [1, 2, 3, 4, 5],
    "y": [100, 120, 90, 105, 115],
    "lower": [90, 110, 80, 95, 105],
    "upper": [110, 130, 100, 115, 125]
})

(
    ggplot(df, aes(x="x", y="y")) 
    + geom_line() 
    + geom_ribbon(
        aes(ymin="lower", ymax="upper"),
        alpha=0.3,
        color="red",
        fill="gray",
        outline_type="both"
    )
)

This leads to a shaded area with only an outline in the lower part: grafik

Using plotnine 0.12.4 and mizani 0.9.3 on Python 3.11.5.