0

我在 R 中制作了一个折线图,现在我想再添加两行已经存在于同一 csv 文件的单独列中的最小值和最大值。这是我使用的代码

plot(MedTemp$Loggers.distance, MedTemp$Temperature..C...2017., xaxt = "n", xlab = "",ylab = "", main = "Median Temperature 2017", col.main = "darkred", col = "blue", pch = 19, ylim = c(-5,25), fill = "blue", type = "o")
axis(1, at = c(0, 4698.91, 5424.74, 8731.54, 10103.81, 14361.29 ), cex.axis = 0.55, las = 2)
lines(MedTemp$Loggers.distance[order(MedTemp$Loggers.distance)], MedTemp$Temperature..C...2017.[order(MedTemp$Loggers.distance)], xlim = range(MedTemp$Loggers.distance), ylim = range(MedTemp$Temperature..C...2017.), pch = 16, col = "firebrick", lwd = 1.5)
text(MedTemp$Temperature..C...2017.~ MedTemp$Loggers.distance, labels = c(" ","Orchar\nHill","Roland\nRoad","Gilligan\nRoad","Wetaskiwin"," "), cex = 0.5, font = 2, pos = 1, srt = 0)
text(MedTemp$Temperature..C...2017.~ MedTemp$Loggers.distance, labels = c("Rice\nRoad"," "," "," "," "," "), cex = 0.5, font = 2, pos = 1, srt = 0)
text(MedTemp$Temperature..C...2017.~ MedTemp$Loggers.distance, labels = c(" "," "," "," "," ","Decew\nRoad"), cex = 0.5, font = 2, pos = 1, srt = 0)
mtext(1, text = "Thermal Loggers Chainage Distance(m)", line = 3, cex = 0.9)
mtext(2, text = "Temperature (C)", line = 3, cex = 0.9)

这是我的数据: Excel的SS

这是我的图表: 剧情SS

任何帮助,将不胜感激。

4

1 回答 1

1

您要查找的命令是abline. 类似的东西

abline(h = c(min_value, max_value))

您可以向函数添加与其他绘图函数类似的颜色、线型、线宽指令。

于 2018-04-08T23:35:33.713 回答