0

编辑:我发现了一种解决方案,即将 2d Temp 矩阵转换为 1D 数组,仅使用此矩阵重新运行代码给了我想要的输出,即按 z 数据的高度着色的绘图。代码如下:

mycols<-colorRampPalette(c("dodgerblue", "firebrick"), space="rgb")  
wireframe(Temp,
      zlim=c(10,18),
      ylab=list(label="Time", rot=-35), scales=list(arrows=FALSE),
      zlab=list(label=expression(paste("Tw (", degree, "C)")), rot=94),
      xlab=list(label="Distance downstream (m)", rot=35),
      drape = T, shade=F, colorkey = T, aspect = c(1,1),
      col.regions=mycols(200), col="black")

我正在使用 Windows 7、R 版本 2.15.0 和 lattice_0.20-6。

我正在使用线框在格子中绘制观察到的数据,我有 3 个观察值矩阵(Temp、Dist、Time),所以我使用公式方法(Temp~Dist*Time)。如何指示线框根据我的 z (Temp) 数据的高度/值对线框进行着色。目前,我的代码会生成一个线框,根据我的 y(时间)数据的值对绘图进行着色。

我附在我的代码下面。

mycols<-colorRampPalette(c("dodgerblue", "firebrick"), space="rgb")  
wireframe(Temp[1:13,97:193]~Dist[1:13,97:193]*Time[1:13,97:193],
      zlim=c(10,18),
      ylab=list(label="Time", rot=-35), scales=list(arrows=FALSE),
      zlab=list(label=expression(paste("Tw (", degree, "C)")), rot=94),
      xlab=list(label="Distance downstream (m)", rot=35),
      drape = T, shade=F, colorkey = T, aspect = c(1,1),
      col.regions=mycols(200), col="black")

一些样本数据。请原谅矩阵列的命名:

structure(list(Tw1.1. = c(12.15, 11.18526437, 10.51390093, 10.134, 
9.711, 9.597, 9.59, 9.557, 9.602, 9.673, 9.753, 10.017, 10.32
), Tw1.1..1 = c(11.97, 11.05071394, 10.39239194, 10.011, 9.63, 
9.546, 9.59, 9.571, 9.648, 9.745, 9.837, 10.171, 10.49), Tw1.1..2 = c(11.79, 
10.90182264, 10.26796411, 9.893, 9.563, 9.52, 9.6, 9.619, 9.713, 
9.808, 9.956, 10.321, 10.6), Tw1.1..3 = c(11.64, 10.74647418, 
10.14505213, 9.788, 9.526, 9.525, 9.62, 9.682, 9.787, 9.914, 
10.105, 10.42, 10.7), Tw1.1..4 = c(11.52, 10.58632287, 10.01657543, 
9.699, 9.514, 9.543, 9.67, 9.743, 9.885, 10.049, 10.249, 10.528, 
10.79), Tw1.1..5 = c(11.39, 10.46294559, 9.879615153, 9.619, 
9.529, 9.577, 9.74, 9.823, 10.017, 10.21, 10.361, 10.58, 10.84
), Tw1.1..6 = c(11.26, 10.3417786, 9.765186747, 9.576, 9.557, 
9.645, 9.81, 9.933, 10.186, 10.344, 10.474, 10.664, 10.94), Tw1.1..7 = c(11.1, 
10.22494533, 9.674806064, 9.546, 9.605, 9.717, 9.9, 10.072, 10.338, 
10.453, 10.557, 10.76, 11.03), Tw1.1..8 = c(10.93, 10.1003152, 
9.604424236, 9.549, 9.676, 9.8, 10, 10.244, 10.436, 10.561, 10.668, 
10.848, 11.12), Tw1.1..9 = c(10.76, 9.970098496, 9.545171854, 
9.577, 9.757, 9.891, 10.15, 10.399, 10.558, 10.667, 10.778, 10.941, 
11.22), Tw1.1..10 = c(10.63, 9.858851801, 9.501869458, 9.611, 
9.851, 10.014, 10.31, 10.503, 10.683, 10.789, 10.868, 11.059, 
11.34), Tw1.1..11 = c(10.51, 9.770908839, 9.48413064, 9.676, 
9.946, 10.164, 10.48, 10.632, 10.8, 10.89, 10.945, 11.152, 11.41
), Tw1.1..12 = c(10.4, 9.702806469, 9.508922546, 9.756, 10.074, 
10.332, 10.59, 10.774, 10.905, 10.96, 11.031, 11.213, 11.48)), .Names = c("Tw1.1.", 
"Tw1.1..1", "Tw1.1..2", "Tw1.1..3", "Tw1.1..4", "Tw1.1..5", "Tw1.1..6", 
"Tw1.1..7", "Tw1.1..8", "Tw1.1..9", "Tw1.1..10", "Tw1.1..11", 
"Tw1.1..12"), class = "data.frame", row.names = c("Open", "B8", 
"B12", "B25", "B26", "B13", "UsAWS", "B19", "B5", "B3", "B27", 
"B17", "DSAWS"))
4

0 回答 0