'How to plot a graph from 2 columns in a dataframe using plotnine?
I am trying to understand how this works
Dataframe is "result"
Column in "result" is Time, Column1, Column2
I am able to plot only a single line from the Column1 from the code below:
(p9.ggplot(data=result,
mapping=p9.aes(x='Time', y='Column1'))
+ p9.geom_point(alpha=0.5)
+ p9.scale_x_datetime(breaks=date_breaks('12 hour'))
)
How to write the code if I wanted it to include Column2? Means plot 2 lines in the chart?
Solution 1:[1]
Why not:
(p9.ggplot(data=result.melt(id_vars = 'Time'),
mapping=p9.aes(x='Time', y='value', color='variable', group = 'variable'))
+ p9.geom_point(alpha=0.5)
+ p9.scale_x_datetime(breaks=date_breaks('12 hour'))
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Timi Bennatan |
