我正在尝试在R中创建一个填充的等高线图,说明整个水柱随时间的水温。水温大约以1米为间隔,但并非总是如此。我可以创建一个填充的等高线图,其中温度采用规则的深度间隔但不是不规则的深度间隔;这个情节看起来像是忽略了不规则间隔收集的温度。下面是我的数据,其中矩阵中的第一行是深度(y),第一列是采样(z)的日期(x)。任何建议或示例代码将不胜感激。
谢谢。
0 1 2 3 3 5 6 7 8 9 10 10.1 10.2 10.5 10.6 10.7 11 11.5
1 6/5/2015 14.79 14.81 14.73 14.73 14.71 14.70 14.71 14.70 14.70 14.70 14.70 NA NA 14.70 NA NA NA NA
2 6/10/2015 17.40 17.40 17.39 17.38 17.40 17.41 17.42 17.39 17.40 17.41 17.42 NA NA NA NA NA NA NA
3 6/18/2015 17.79 17.75 17.75 17.75 17.74 17.75 17.74 17.74 17.74 17.74 17.74 NA NA NA NA NA NA NA
4 6/29/2015 17.38 17.39 17.40 17.40 17.38 17.34 17.34 17.33 17.33 17.32 17.32 NA NA NA NA NA NA NA
5 7/7/2015 20.66 20.59 20.56 20.43 20.05 20.04 20.04 20.04 20.04 20.04 20.03 NA 20.04 NA NA NA NA NA
6 7/15/2015 24.16 24.16 24.14 24.12 24.12 24.12 24.12 24.13 24.14 24.14 24.14 NA NA 24.14 NA NA NA NA
7 7/23/2015 22.15 21.97 21.80 21.82 21.79 21.81 21.81 21.82 21.82 21.82 21.83 21.83 NA NA NA NA NA NA
8 7/29/2015 25.45 24.73 23.87 23.84 23.84 23.85 23.85 23.85 23.85 23.84 23.84 NA 23.84 NA NA NA NA NA
9 8/5/2015 25.19 25.04 24.40 24.35 24.33 24.30 24.24 24.23 24.21 24.18 24.17 NA NA NA NA NA NA NA
10 8/12/2015 24.01 23.88 23.68 23.58 23.53 23.52 23.52 23.54 23.57 23.60 23.58 NA NA NA NA 23.63 NA NA
11 8/19/2015 25.25 25.06 25.01 24.99 24.91 24.91 24.91 24.91 24.91 24.91 24.91 NA NA NA 24.91 NA NA NA
12 8/28/2015 25.30 24.96 24.37 24.32 24.29 24.27 24.25 24.24 24.23 24.23 24.23 NA NA NA NA NA 24.23 24.23
13 9/9/2015 25.36 25.19 24.97 24.79 24.71 24.67 24.63 24.62 24.62 24.61 24.60 NA NA NA NA NA 24.60 NA
答案 0 :(得分:0)
以下是使用基础R中的filled.contour()
函数创建填充等高线图的一种方法。生成的等高线图不受不规则间隔的限制,而是受到深度大于10的数据的限制。 / p>
mat <- structure(c(14.79, 17.4, 17.79, 17.38, 20.66, 24.16, 22.15, 25.45,
25.19, 24.01, 25.25, 25.3, 25.36, 14.81, 17.4, 17.75, 17.39,
20.59, 24.16, 21.97, 24.73, 25.04, 23.88, 25.06, 24.96, 25.19,
14.73, 17.39, 17.75, 17.4, 20.56, 24.14, 21.8, 23.87, 24.4, 23.68,
25.01, 24.37, 24.97, 14.73, 17.38, 17.75, 17.4, 20.43, 24.12,
21.82, 23.84, 24.35, 23.58, 24.99, 24.32, 24.79, 14.71, 17.4,
17.74, 17.38, 20.05, 24.12, 21.79, 23.84, 24.33, 23.53, 24.91,
24.29, 24.71, 14.7, 17.41, 17.75, 17.34, 20.04, 24.12, 21.81,
23.85, 24.3, 23.52, 24.91, 24.27, 24.67, 14.71, 17.42, 17.74,
17.34, 20.04, 24.12, 21.81, 23.85, 24.24, 23.52, 24.91, 24.25,
24.63, 14.7, 17.39, 17.74, 17.33, 20.04, 24.13, 21.82, 23.85,
24.23, 23.54, 24.91, 24.24, 24.62, 14.7, 17.4, 17.74, 17.33,
20.04, 24.14, 21.82, 23.85, 24.21, 23.57, 24.91, 24.23, 24.62,
14.7, 17.41, 17.74, 17.32, 20.04, 24.14, 21.82, 23.84, 24.18,
23.6, 24.91, 24.23, 24.61, 14.7, 17.42, 17.74, 17.32, 20.03,
24.14, 21.83, 23.84, 24.17, 23.58, 24.91, 24.23, 24.6, NA, NA,
NA, NA, NA, NA, 21.83, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
20.04, NA, NA, 23.84, NA, NA, NA, NA, NA, 14.7, NA, NA, NA, NA,
24.14, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 24.91, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
23.63, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
24.23, 24.6, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 24.23,
NA), .Dim = c(13L, 18L), .Dimnames = list(c("6/5/2015", "6/10/2015",
"6/18/2015", "6/29/2015", "7/7/2015", "7/15/2015", "7/23/2015",
"7/29/2015", "8/5/2015", "8/12/2015", "8/19/2015", "8/28/2015",
"9/9/2015"), c("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "10.1", "10.2", "10.5", "10.6", "10.7", "11", "11.5")))
dates <- as.Date(dimnames(mat)[[1]], "%m/%d/%Y")
depths <- as.numeric(dimnames(mat)[[2]])
filled.contour(x=dates, y=depths, z=mat, xlab="Date", ylab="Depth")