Closed YonghuiDong closed 5 years ago
That should definitely be possible using a data.tree
input, which grants a much greater degree of flexibility than a data frame. Have you tried that?
Dear Adeel Khan,
Thanks a lot for your prompt reply. My data was generated using data.tree. But I am not familiar with
collapsibleTree
package, I don't know how to colour tree nodes using the first hierarchy.
I use a simple example here, in which I would like to colour the node based on continent, countries belong to the same continent will have the same colour, and colours for countries belong to different continent will be different.
Could you please help me how to do it?
Thanks a lot.
## prepare the data
library(data.tree)
library(collapsibleTree)
library(treemap)
data(GNI2014)
GNI2014$pathString <- paste("world",
GNI2014$continent,
GNI2014$country,
sep = "/")
## plot
collapsibleTree(
GNI2014,
hierarchy = c("continent", "country"),
width = 800,
zoomable = FALSE
)
Thanks, problem solved.
Hi AdeelK93,
How to colour the tree nodes based on only levels of the first hierarchy ?
Thanks.