R - hist3D colors of the sequence of colors and labels

So I have a dataset with 5 rows and 20 columns. I am trying to build hist3D

from a package plot3D

.

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")))

      

bar chart

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

      

the figure

I would like to

  • replace x-axis

    (1: 5) with row.names ( "f Housework", "g Odd jobs", "h Eating", "i Child care", "j Care for others"

    )

  • Instead of having the same colors for each variable x

    , my data lines (1: 5, "f Housework", "g Odd jobs", "h Eating", "i Child care", "j Care for others"

    ), I would like to have a different color for each line (if possible, different colors of the heatmap sequence).

What I would like is something like this (manual draw I know):

enter image description here

Any advice?

+3


source to share


2 answers


I think I have a solution for colors: enter image description here

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")

      



I will update the post as soon as I know how to change the X-axis labels.

+3


source


If you haven't figured it out yet (or for the next person who comes along with a similar issue), there is an awesome blog here on how to change all topology objects in hist3D: http://entrenchant.blogspot.co.uk/2014_03_01_archive.html



+5


source







All Articles