I'm trying to plot a Pandas DataFrame with python ggplot. The DF has four columns: Date, Val1, Val2, Condition. What I want is a line plot with both Val1 and Val2 as y-coordinate, Date as the x coordinate and facet wrap with Condition.
I can do either of these in isolation but I'm not able to do both things at once. Here is what I tried:
ggplot(DF, aes(x='Date', y = 'Val1')) + geom_line()+ geom_line(aes(x='Date', y = 'Val2'), colour='red') + facet_wrap('Condition')
However, this only shows the facet_wrap plots of Val1 but coloured red. If I omit the facet_wrap, it plots both line plots perfectly.
What am I doing wrong?
Any help will be much appreciated. Thanks in advance!
If you restructure your dataframe to instead have 3 columns instead (Date, Val, Condition) it will split into two plots by condition.
ggplot(DF, aes(x='Date', y = 'Val1')) + geom_line() + facet_wrap('Condition')
If you look at the dataframe used in the examples found here https://yhat.github.io/ggpy/notebook.html?page=build/docs/examples/Faceting%20Basics.html you'll see that there is only one column for values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With