I have a ggplot with data from three data frame within a list. Each data frame has a "date" and a "measurement" vector. These are hourly data from instrumentation. I have a separate list with three data frames that have manual data points. These data are collected once a month. The naming of the data frames is consistent within each list, but .
What I want to do, is to plot the manual data as points overtop of the hourly data.
I've managed to get pretty close to what I want with this code:
p1 <- ggplot(data_list[["Inst1"]],aes(date,elevation))+geom_line(aes(color="Instrument 1"))+
geom_line(data=data_list[["Inst2"]],aes(color="Instrument 2"))+
geom_line(data=data_list[["Inst3"]],aes(color="Instrument 3"))+
geom_point(data=man_list[["Inst1"]],aes(date,water_el,color="Instrument 1",size = "3"))+
geom_point(data=man_list[["Inst2"]],aes(date,water_el,color="Instrument 2",size = "3"))+
geom_point(data=man_list[["Inst3"]],aes(date,water_el,color="Instrument 3",size = "3"))+
labs(color="")
There are two main issues I don't know how to resolve.
1) I'd prefer to have the Legend show the manual points labelled separately from the hourly data (lines). I realize that using colour to generate the legend is the issue here, but I'm not sure what other approach I can take. I want the colours of the points and lines to be the same, however.
2) I'm not sure why size is showing up in the legend.
Help?
UPDATE:
str(data_list)
List of 5
$ Inst1 :'data.frame': 7735 obs. of 4 variables:
$ date: POSIXct[1:7735], format: "2016-01-22 01:56:00" "2016-01-22 02:56:00" ...
$ measurement: num [1:7735] 1.73 1.73 1.73 1.73 1.74 ...
$ trans_el : num [1:7735] 341 341 341 341 341 ...
$ elevation : num [1:7735] 343 343 343 343 343 ...
str(man_list)
List of 5
$ Inst1 :'data.frame': 14 obs. of 6 variables:
$date : POSIXct[1:14], format: "2015-12-07 15:16:00" "2015-12-23 15:51:00" ...
$ man : num [1:14] 3.69 4.33 4.28 4.07 3.71 ...
$ trans_h2o : num [1:14] NA NA NA 1.72 2.08 ...
$ trans_el : num [1:14] NA NA NA 341 341 ...
$ water_el : num [1:14] 343 342 342 343 343 ...
$ trans_el_round: num [1:14] NA NA NA 341 341 ...
Each list has 5 data frames of Inst1 to Inst 5. Within a given list, each data frame is set up the same (has same variables and names). BUT the date vectors are different for each data frame, and are different between each list.
So,
data_list[["Inst1"]]$date =/ data_list[["Inst2"]]$date
and
data_list[["Inst1"]]$date =/ man_list[["Inst1"]]$date

fillinstead ofcolorforgeom_point()2) movesize = "3"outside ofaes- Nategeom_pointandgeom_line. If possible, please paste into your question the output ofdput(lapply(data_list, head))and the output ofdput(lapply(man_list, head)). - eipi10