我正在通过鸽子轨道计算导航测量到矩阵。输出看起来像下面的示例代码所生成的数据框。每行是不同的窗口长度,而每列是自发布以来的秒数。对于无数据,数据范围在0之间,对于数据,数据范围在0.001到1之间。
我想要做的是将每个点绘制为XY图上的非重叠方块,沿着色标。所以0 =白色(没有数据),而0.001-0.1是深蓝色,0.101-.2是浅蓝色等。是否有绘图方法可以做到这一点?
example.data<-c(0.000,0.000,0.000,0.000,0.000,1.000,0.000,0.000, 0.000,0.000,1.000,0.956,0.000,0.000,0.000,1.000,0.991,0.948,0.000,0.000,1.000,0.989,0.985,0.944,0.000,1.000,0.998,0.993,0.989,0.954,1.000,0.995,0.100,4.000,0.990,1.000,0.987,0.500,0.600,0.986,1.000,0.993,0.450,0.200,0.250)
example.data<-as.matrix(example.data[1:5,1:9] )
names(example.data<)<-paste("Seconds",c(1:9))
row.names(example.data<)<- paste("Window",c(1:5))
答案 0 :(得分:2)
您可以重塑为矩阵(使用matrix
代替as.matrix
),然后使用image()
进行可视化。我为您的数据集添加了一个值,因此它是5x9而不是44个元素...
numrows = 5
numcols = 9
example.matrix = matrix(example.data,numrows,numcols)
image(example.matrix,col=blue9)
输出:
答案 1 :(得分:0)
查看情节heatmap
。你需要一个数字矩阵
x <- as.matrix(example.data)
heatmap(x[1:10,1:10],Rowv=NA,Colv=NA,reorderfun=NA,hclustfun=NA)
但是,如果你尝试绘制所有数据,你会得到一个多色的混乱,但实际上并没有说什么。