Hi ggplot users,
I don't know how to draw one variable reversed while the other one normal order on y-axis in ggplot?
df
month A B
1 10 0.5
2 15 0.7
3 18 0.8
4 16 1
5 20 1.1
6 12 0.6
plot1= ggplot()+geom_path(data=df,aes(x=month,y=B))+
scale_y_continuous(trans='reverse')
print(plot1)
But if I want to put only B reversed, and plot A on the same plot but in normal y-axis. how to do it? the code does not work
plot2 = ggplot()+geom_path(data=df,aes(x=month,y=B,color='b'))+
geom_path(data=df,aes(x=month,y=A,color='a'))+scale_y_continuous(trans='reverse')+scale_color_manual(limits=c('b','a'),values=c('red','blue'))
print(plot2)
also, I want to apply the trans='reverse' only to B variable. Thanks for your help.