绘制数据框的曲线

时间:2018-10-04 03:30:43

标签: r

df1 <- read.csv("C:\\Users\\Unique\\Desktop\\Data Science\\
                 R Scripts\\LimeBison_ch1.csv")

df2 <-  df1[df1[,3] ==  73.608125,]

plot(df2[,1],df2[,2], xlab = "Milliseconds", ylab = "Amplitude", 
  main = "Amplitude vs Time Graph",type = "p", pch =16, col = "red",
    xlim = c(-200,1200), ylim = c(-1.5,1.5))

x <- tapply(df2$Amplitude, df2$Time, mean)

df3 <- data.frame(Time = names(x), Average_Amplitude = x)

如何在df2的散点图上绘制数据帧df3的曲线?

1 个答案:

答案 0 :(得分:0)

我不确定您的数据,但是如果您使用的是基本绘图,则可以使用lines函数在散点图上方绘制一条线

df <- data.frame(x = 1:40, y = c(1:20, 20: 1))
plot(df$x, df$y, cex = 2)
lines(df$x, df$y)