使用两个几何时添加图例

时间:2019-04-16 18:24:14

标签: r ggplot2

我正在尝试创建一个由两个数据框构成的绘图:

#simple df1, mine is a little more complicated 
df1 <- data.frame(time = seq(0.01,40.01,by=0.01), y=seq(0.01, 0.05, by=0.00001))
df2 <- data.frame(time = c(0.6082192 , 1.4821918 , 1.9315068 , 2.5287671,  3.4821918 , 4.6000000 , 5.1835616 , 6.4986301 , 7.2712329 , 7.8986301,9.4383562 ,10.3479452 ,11.1589041 ,14.5753425 ,17.7205479 ,38.7123288), rate = c(0.0167,0.0168,0.0174,0.0165,0.0165,0.0173,0.0161,0.017,0.0177,0.0183,0.0183,0.0178,0.0196,0.0226,0.0245,0.0278)
plot <- ggplot()+
  geom_line(data = df1, aes(x=time, y=y))+
  geom_point(data = df2, aes(x=Time, y=rate),col="red")

plot(plot)

产生this。但是,我无法在其中放置图例,因此它看起来更像this(不必担心线条的形状)。

0 个答案:

没有答案