I’d like to graph some data as means of groups over time, with lines connecting the different mean time points for each group.
The code for this is:
line<-ggplot(dat, aes(Time, Cortisol.ngmL, shape=T))
line+
stat_summary(fun.y=mean, geom="point", size=4, aes(group=T))+
stat_summary(fun.y=mean, geom="line", aes(group=T), linetype="dashed", lwd=0.7)
But…I want the y axis logged (log10). And when I do this the lines connecting the groups across time become curved (code below)
line<-ggplot(dat, aes(Time, Cortisol.ngmL, shape=T))
line+
stat_summary(fun.y=mean, geom="point", size=4, aes(group=T))+
stat_summary(fun.y=mean, geom="line", aes(group=T), linetype="dashed", lwd=0.7)+
coord_trans(y="log10")
Does anyone know a way I can have a log scale and straight lines?
library(ggplot2); x <- seq(from=1, to=10, by=0.1); ggplot() + geom_line(aes(x = x, y = x), colour = "red") + geom_line(aes(x = (9/log10(10))*log10(x) + 1, y = x), colour = "blue") + coord_trans(y="log10")No idea how to generalise that for any two points though - Mist