I am trying to create a plot using ggplot2 that includes both geom_smooth and geom_point. Since I want to see the slope of the line and how it changes over time, I would like color the geom_smooth line one color (Timepoint) and the points a different color (by plot). I have tried various different things, but they all fail. Including some of the options that I have found here on stackoverflow.
My code is as follows:
##Edited code to show as of 7/28
ggplot(data, aes(x = InitialAshDepth, y = S.obs, color =TimePoint)) +
geom_point(size = 3.5, aes(fill = Plot))+
geom_smooth(method = "lm", alpha=0.15, aes(color = TimePoint)) +
#geom_smooth( method=lm, alpha=0.15,aes(group = TimePoint,
color=TimePoint))+
scale_color_manual(values = TP) +
theme_bw()
Can someone please let me know how I can go about achieving this and or if this is even possible?
Please note that I have tried grouping by and just color by or a combination of both (when I do a combination of both, I get an error stating I need 700+ colors)??
This is the graph that I have created but the points are not being colored differently from the geom_smooth lines. Sorry, I am not allowed to embed pictures, but please see the link.
Here is an example of my data with the columns I am working with. Here I only show three timepoints just for the sake of saving space but I actually have 9-time points. Please see image as the data gets distorted when I copy and paste.
Sample data:
Plot TimePoint Treatment SpeciesRichness
1 TP1 Burned 88
1 TP2 Burned 66
1 TP3 Burned 60
2 TP1 Burned 119
2 TP2 Burned 55
2 TP3 Burned 44
3 TP1 Burned 35
3 TP2 Burned 34
3 TP3 Burned 22
4 TP1 Burned 63
4 TP2 Burned 49
4 TP3 Burned 9
5 TP1 Burned 26
5 TP2 Burned 35
5 TP3 Burned 66
6 TP1 Burned 21
6 TP2 Burned 85
6 TP3 Burned 65
7 TP1 Unburned 57
7 TP2 Unburned 169
7 TP3 Unburned 110
8 TP1 Unburned 166
8 TP2 Unburned 180
8 TP3 Unburned 114
9 TP1 Unburned 270
9 TP2 Unburned 194
9 TP3 Unburned 328