has2k1 / plotnine

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

Area chart with gradient #591

Open jrr96 opened 2 years ago

jrr96 commented 2 years ago

Is there any way to achieve a gradient in the filling of an area chart?

Capture

I have not been able to find anything in the docs.

If not, how feasible would it be to add this feature? I think it greatly improves the aesthetics of area charts.

Thanks a lot in advance!

has2k1 commented 2 years ago

It is not possible, and I do not know if it can be implemented cleanly (without trying).

jrr96 commented 2 years ago

If I am understanding the philosophy, the code should look something like this right?

(
ggplot(df, aes(x='date', y='value', alpha='value'))
+ scale_alpha(range=(0, 1))
+ geom_area()
)
has2k1 commented 2 years ago

If I am understanding the philosophy, the code should look something like this right?

(
ggplot(df, aes(x='date', y='value', alpha='value'))
+ scale_alpha(range=(0, 1))
+ geom_area()
)

Maybe or maybe not only that. The gradient may come from the alpha or from the fill (the continuous colour range) or even both. The key to implementing though, is that it should be supported by the underlying drawing system; that is the hard part!