我有以下等高线图
x <- c(0,25,50,75,100)
y <- c(0,10,20)
z <- matrix(c(12,12,13,12,5,12,5,5,5,12,5,12,13,14,15), nrow = 5, ncol = 3, byrow = TRUE)
A <- matrix(seq(0, 100, by = 25), nrow = 3, ncol = 5, byrow = TRUE) #As x
B <- matrix(seq(0,20, by = 10), nrow = 3, ncol = 5) #As y
filled.contour(x,y,z, color=terrain.colors,#
plot.axes = { axis(1); axis(2); points(A,B)})
如何在值5的水平周围绘制一个水平线并标记它并获得如下内容:
答案 0 :(得分:1)
您可以在contour
中使用plot.axes
。不可能将行添加到5,所以我使用了5.01而是指定了labels
。这至少是原则。
filled.contour(x, y, z, color = terrain.colors,
plot.axes = {axis(1); axis(2); points(A, B);
contour(x, y, z, levels = 5.01, labels = "5", col = "red", add = TRUE)})
答案 1 :(得分:0)
library(fields)
library(emdbook)
x <- c(0,25,50,75,100)
y <- c(0,10,20)
z <- matrix(c(12,12,13,12,5,12,5,5,5,12,5,12,13,14,15), nrow = 5, ncol = 3, byrow = TRUE)
A <- matrix(seq(0, 100, by = 25), nrow = 3, ncol = 5, byrow = TRUE) #As x
B <- matrix(seq(0,20, by = 10), nrow = 3, ncol = 5) #As y
image.plot(x,y,z)
contour(x,y,z,
add=TRUE, lwd=2, cex=2)