R - 序列颜色和标签问题的 hist3D

R - hist3D of sequence colour and label issues

所以我有一个包含 5 行和 20 列的数据集。 我正在尝试从 plot3D 包中绘制一个 hist3D

dt = structure(c(1, 1, 1, 3, 1, 2, 1, 0, 2, 1, 2, 1, 0, 1, 1, 0, 1, 
0, 2, 2, 1, 1, 1, 1, 4, 4, 1, 1, 2, 3, 8, 1, 1, 2, 1, 10, 0, 
1, 2, 1, 9, 0, 2, 4, 0, 4, 0, 5, 2, 2, 2, 0, 1, 2, 4, 1, 1, 3, 
2, 6, 8, 1, 2, 2, 4, 10, 0, 2, 2, 4, 7, 0, 7, 1, 4, 11, 0, 4, 
1, 2, 15, 0, 4, 2, 3, 16, 2, 7, 2, 2, 18, 3, 9, 0, 1, 15, 0, 
15, 0, 2), .Dim = c(5L, 20L), .Dimnames = list(c("f Housework", 
"g Odd jobs", "h Eating", "i Child care", "j Care for others"
), c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", 
"V11", "V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19", 
"V20")))

直方图

hist3D(x = 1:5, z = dt, scale = T, col = jet.col(100, alpha = 0.3), add = F,  colkey = F, ticktype = "detailed")

我想要的是

  1. x-axis (1:5) 替换为 row.names ("f Housework", "g Odd jobs", "h Eating", "i Child care", "j Care for others" )

  2. 我的数据行(1:5,"f Housework", "g Odd jobs", "h Eating", "i Child care", "j Care for others")不是每个 x 变量都使用相同的颜色,而是 我想为每一行设置不同的颜色(如果可能的话,使用不同的 "heat-map" 序列颜色)。

我想要的是这样的(我知道的是手动绘制):

有什么建议吗?

我想我有一个颜色的解决方案:

m <- matrix(rep(seq(5),each=20), ncol=20, nrow=5, byrow = TRUE)
hist3D(x = 1:5, z = dt, scale = T, col = jet.col(5, alpha = 0.3), add = F,  colvar = m, colkey = T, ticktype = "detailed")

我会在找到如何修改 x 轴标签后立即更新 post。

如果您还没有弄明白(或者对于遇到类似问题的下一个人),这里有一个很棒的博客 post 关于改变 hist3D 中的所有轴的东西:http://entrenchant.blogspot.co.uk/2014_03_01_archive.html