r - Colour lattice wireframe from class formula by z data heights -
edit: i've discovered 1 solution, transform 2d temp matrix 1d array, re-running code matrix gave me output wanted i.e. plot coloured height of z data. code below:
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")
i'm using windows 7, r version 2.15.0 , lattice_0.20-6.
i'm plotting observed data in lattice using wireframe, have 3 matrices of observed values (temp,dist,time) i'm using formula method (temp~dist*time). how instruct wireframe colour wireframe based on heights/ values of z (temp) data. @ present code produces wireframe colours plot based on values of y (time) data.
i attach below code.
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")
some sample data. please excuse naming of matrix columns:
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"))
Comments
Post a Comment