确定, [R3.4.2 + ggplot2] 使用下面列出的数据示例,如何添加第二个数据图?我试过这个我在这个网站上找到的例子;
library(ggplot2]
** This is part of the origanl code ****
rpt<-read.csv(file="rpt.csv,header=T)
rpt1<-read.csv(file="rpt1.csv,header=T)
*** code starts here *****
ggplot(rpt,aes(JulianDate,w)) + geom_line(aes(color="First line")) +
geom_line(data=rpt1, aes(color="Second line")) + labs(color="Legend text")
第一个图有x = rpt $ JulianDate,y = rpt1 $ w;第二个图有x1 = rpt1 $ JDAy和y2 = rpt1 $ wolf)
数据(使用dget(_)读取它):
structure(list(
JDay = c(57023, 57024, 57027, 57028, 57029, 57031, 57032, 57035, 57037),
Obs = c(1, 1, 1, 1, 1, 1, 1, 1, 1),
w = c(71, 105, 64, 44, 45, 38, 66, 49, 28),
WStd = c(0, 0, 0, 0, 0, 0, 0, 0, 0),
wolf = c(91.59, 135.45, 82.56, 56.76, 58.05, 49.02, 85.14, 63.21, 36.12),
Adj = c(0, 0, 0, 0, 0, 0, 0, 0, 0)),
.Names = c("JDay", "Obs", "w", "WStd", "wolf", "Adj"),
class = "data.frame",
row.names = c(NA, -9L))