如何使用levelplot

时间:2017-02-04 03:40:08

标签: r plot lattice levelplot

我有一个这样的数据框:

>x
      r      z   rho
1  2.90 -11.20 0.000
2  2.90 -11.15 0.000
3  2.90 -11.10 0.000
4  2.90 -11.05 0.000
5  2.95 -11.45 0.000
6  2.95 -11.40 0.000
7  2.95 -11.35 0.000
8  2.95 -11.30 0.000
9  2.95 -11.25 0.000
10 2.95 -11.20 0.002
11 2.95 -11.15 0.004
12 2.95 -11.10 0.002
13 2.95 -11.05 0.006
14 3.00 -11.45 0.010
15 3.00 -11.40 0.000
16 3.00 -11.35 0.001

>y
  r      z        rho
1  2.90 -11.20 0.01666389
2  2.90 -11.15 0.01666389
3  2.90 -11.10 0.01666389
4  2.90 -11.05 0.01666389
5  2.95 -11.45 0.03332778
6  2.95 -11.40 0.00000000
7  2.95 -11.35 0.00000000
8  2.95 -11.30 0.00000000
9  2.95 -11.25 0.00000000
10 2.95 -11.20 0.00000000
11 2.95 -11.15 0.00000000
12 2.95 -11.10 0.00000000
13 2.95 -11.05 0.00000000
14 3.00 -11.45 0.00000000
15 3.00 -11.40 0.00000000
16 3.00 -11.35 0.00000000

行数是241401.所以它基本上是一个矩阵。 r和z可以被认为是x和y,rho告诉你特定行col的值。我想用levelplot绘制它。现在我正在使用这样的东西:

library(RColorBrewer)
library(latticeExtra)
library(lattice)
x <- read.table("fakedata.txt",header=FALSE) 
y <- read.table("fake2.txt",header=FALSE)
colnames(x) <- c("r","z","rho")
colnames(y) <- c("r","z","rho") 
levelplot(y$rho ~ y$r + y$z) 
levelplot(x$rho ~ x$r + x$z)

x和y的图是: enter image description here enter image description here 但是,我希望所有正方形的粉红色都可以为x所有正方形绘制彩色和蓝色。

有什么建议吗?

0 个答案:

没有答案