R 3d距离矩阵图与彩色点

时间:2016-07-11 18:32:26

标签: r plot

我使用 A B C D E A 0 0.1 0.2 0.1 0.2 B 0.1 0 0.1 0.2 0.1 C 0.2 0.1 0 0.1 0.2 D 0.1 0.2 0.1 0 0.1 E 0.2 0.1 0.2 0.1 0 在R中绘制了距离矩阵,现在想为每个点指定一种独特的颜色。例如,在以下示例中,绘图将包含五个点( A-E ):

scatterplot3d

目前,关于积分外观的s3d <- scatterplot3d(x,y,z, main="Just A Test", pch = 19) 代码非常简单:

datatype: 'local'

如何使每个点显示不同的颜色(使用十六进制代码)?

1 个答案:

答案 0 :(得分:0)

Have you looked at the color argument in ?scatterplot3d .... ?

dd <- read.table(header=TRUE,text="
       A       B       C       D       E 
A      0      0.1     0.2     0.1     0.2
B     0.1      0      0.1     0.2     0.1
C     0.2     0.1      0      0.1     0.2
D     0.1     0.2     0.1      0      0.1
E     0.2     0.1     0.2     0.1      0")

Here I'm assuming you want to use columns A-C as your coordinates ...

library(scatterplot3d)
## some made-up colors
cols <- c("#000000","#fa0ace","#eeabce","#5a0af0","#883856")
s3d <- with(dd,scatterplot3d(A,B,C, 
    main="Just A Test", pch = 19, color=cols,cex.symbols=3))

enter image description here