[英]3d histogram graphs color for each range in R
I would like to know is there any way that I can have different color for different range in the 3D histogram graphs in R. 我想知道在R中的3D直方图中是否有任何可以为不同范围设置不同颜色的方法。
For example, ı have a table, and ı want to colour the same ranges with yellow. 例如,ı有一张桌子,并且我想用黄色着色相同的范围。 (table[1,1], table[2,2], table[3,3] ... table[12,12] = colour "yellow"; table[1,2],table[1,3], table[2,3],table[2,4] ....= colour "green"; table[2,1],table[3,1],table[8,5].... = colour "red". How can ı do this?
(表[1,1],表[2,2],表[3,3] ...表[12,12] =颜色“黄色”;表[1,2],表[1,3],表[2,3],表[2,4] .... =颜色“绿色”;表[2,1],表[3,1],表[8,5] .... =颜色“红色“。怎么能这样做?
My table data; 我的表数据;
A B C D E F G H I J K L
A 2 7660 1868 673 138 83 13 0 0 0 0 0
B 34 61426 21333 7849 2039 1204 150 3 1 0 1 0
C 8 23539 16409 9646 2309 2088 193 6 2 2 0 0
D 3 12209 12748 12516 3943 4342 547 12 1 1 1 0
E 0 1848 2957 5656 3402 6712 1500 31 0 1 1 0
F 0 3 24 521 637 1798 614 9 2 0 1 0
G 0 0 0 828 1284 4496 2142 44 3 1 1 0
H 0 0 0 195 457 2097 1416 65 0 0 1 1
I 0 0 0 0 161 1327 1355 98 8 3 1 0
J 0 0 0 0 52 559 693 69 8 0 0 1
K 0 0 0 0 40 431 669 97 11 5 0 1
L 0 0 0 0 0 0 0 0 0 0 0 0
hist3D (x = 1:12, y = 1:12, z = table1,bty = "g", phi = 20,
theta = -60,xlab = "Income", ylab = "ModelIncome", zlab = "Counts",
main = "Income&ModelIncome",col = "#0072B2",border = "black",
shade = 0.8,ticktype = "detailed", space = 0.15, d = 2, cex.axis = 1e-9)
Here's a way to adjust the colors by table indices: 这是一种通过表索引调整颜色的方法:
table1 <- read.table(header=T, text=" A B C D E F G H I J K L
A 2 7660 1868 673 138 83 13 0 0 0 0 0
B 34 61426 21333 7849 2039 1204 150 3 1 0 1 0
C 8 23539 16409 9646 2309 2088 193 6 2 2 0 0
D 3 12209 12748 12516 3943 4342 547 12 1 1 1 0
E 0 1848 2957 5656 3402 6712 1500 31 0 1 1 0
F 0 3 24 521 637 1798 614 9 2 0 1 0
G 0 0 0 828 1284 4496 2142 44 3 1 1 0
H 0 0 0 195 457 2097 1416 65 0 0 1 1
I 0 0 0 0 161 1327 1355 98 8 3 1 0
J 0 0 0 0 52 559 693 69 8 0 0 1
K 0 0 0 0 40 431 669 97 11 5 0 1
L 0 0 0 0 0 0 0 0 0 0 0 0")
table1 <- as.matrix(table1)
library(plot3D)
colvar <- structure(rep(NA, prod(dim(table1))), .Dim =dim(table1), .Dimnames = dimnames(table1))
diag(colvar) <- 1
colvar[2, ] <- 2
colvar[, 3] <- 3
hist3D (x = 1:12, y = 1:12, z = table1,bty = "g", phi = 20,
theta = -60,xlab = "Income", ylab = "ModelIncome", zlab = "Counts",
main = "Income&ModelIncome",col = c("blue", "yellow", "red"),border = "black",
shade = 0.8,ticktype = "detailed", space = 0.15, d = 2, cex.axis = 1e-9, colvar = colvar)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.