从cvs(x,y,c)矩阵

时间:2015-06-02 20:58:56

标签: r contour

我正在尝试将R用于此任务 - 从csv文件,(x,y,c)矩阵创建填充等高线图。我从足球场得到了我的测量结果 - x和y表示场地中的位置,范围从1到11.c是测量值。

以下是数据:

,1,2,3,4,5,6,7,8,9,10,11
1,0,0,0,0,0,0,0,0,0,0,0
2,0,0,0,0.4,0.6,0.6,0.6,0.4,0,0,0
3,0,0,0.5,0.7,0.8,0.8,0.8,0.7,0.5,0,0
4,0,0.4,0.7,0.8,0.9,0.9,0.9,0.8,0.7,0.4,0
5,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0
6,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0
7,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0
8,0,0.4,0.7,0.8,0.9,0.9,0.9,0.8,0.7,0.4,0
9,0,0,0.5,0.7,0.8,0.8,0.8,0.7,0.5,0,0
10,0,0,0,0.4,0.6,0.6,0.6,0.4,0,0,0
11,0,0,0,0,0,0,0,0,0,0,0

请提供一个绘制填充轮廓的示例。

1 个答案:

答案 0 :(得分:0)

z <- as.matrix(read.csv(text=',1,2,3,4,5,6,7,8,9,10,11\n1,0,0,0,0,0,0,0,0,0,0,0\n2,0,0,0,0.4,0.6,0.6,0.6,0.4,0,0,0\n3,0,0,0.5,0.7,0.8,0.8,0.8,0.7,0.5,0,0\n4,0,0.4,0.7,0.8,0.9,0.9,0.9,0.8,0.7,0.4,0\n5,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0\n6,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0\n7,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0\n8,0,0.4,0.7,0.8,0.9,0.9,0.9,0.8,0.7,0.4,0\n9,0,0,0.5,0.7,0.8,0.8,0.8,0.7,0.5,0,0\n10,0,0,0,0.4,0.6,0.6,0.6,0.4,0,0,0\n11,0,0,0,0,0,0,0,0,0,0,0\n',row.names=1));
z;
##    X1  X2  X3  X4  X5  X6  X7  X8  X9 X10 X11
## 1   0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0   0
## 2   0 0.0 0.0 0.4 0.6 0.6 0.6 0.4 0.0 0.0   0
## 3   0 0.0 0.5 0.7 0.8 0.8 0.8 0.7 0.5 0.0   0
## 4   0 0.4 0.7 0.8 0.9 0.9 0.9 0.8 0.7 0.4   0
## 5   0 0.6 0.8 0.9 1.0 1.0 1.0 0.9 0.8 0.6   0
## 6   0 0.6 0.8 0.9 1.0 1.0 1.0 0.9 0.8 0.6   0
## 7   0 0.6 0.8 0.9 1.0 1.0 1.0 0.9 0.8 0.6   0
## 8   0 0.4 0.7 0.8 0.9 0.9 0.9 0.8 0.7 0.4   0
## 9   0 0.0 0.5 0.7 0.8 0.8 0.8 0.7 0.5 0.0   0
## 10  0 0.0 0.0 0.4 0.6 0.6 0.6 0.4 0.0 0.0   0
## 11  0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0   0
filled.contour(z,color.palette=terrain.colors);

plot