'How do I change the geom lines between group categories across different timepoints (ggplot)?
Just started learning ggplot and I'm trying to change my groups to show different geom lines (i.e. one dashed, one smooth/straight line). Below is a mock of my code and how my plot currently looks:
ggplot(longdat,aes(visitnum,score, colour=Groups)) +
stat_summary(fun.y="mean", geom="line", size=.25 ) + stat_summary(fun.y="mean", geom="point") +
scale_x_continuous(name="Timepoints",breaks=c(0,4,12),labels=c("Time 1","Time 4","Time 12")) +
scale_y_continuous(name="Levels") +
theme(axis.text.x=element_text(angle=45,hjust=1))
I want to change the plot to black and white. However before I do that, I would need to change the lines so I can clearly see the difference between the 2 groups in b&w.
Below is my current code but it seems to re-connect the timepoints in a weird way:
ggplot(longdat,aes(visitnum,score, group=Groups)) +
geom_line(aes(linetype=Groups)) +
geom_point() +
stat_summary(fun.y="mean", size=.25 ) + stat_summary(fun.y="mean") +
scale_x_continuous(name="Timepoints",breaks=c(0,4,12),labels=c("Time 1","Time 4","Time 12")) +
scale_y_continuous(name="Levels") +
theme(axis.text.x=element_text(angle=45,hjust=1))
I've managed to change the group line types (albeit still not as obvious b/w the two groups), but now its connecting the mean scores between the 3 timepoints in a weird way...
Not sure what's causing this, or whether I have to implement the "geom_line" and "geom_point" functions within my "stat_summary" functions?
Any assistance would be appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


