how to plot the data in plotly treemap and keep each category next to each other as block and apply different color to each category?
data <- data.frame(
category = rep(c("Group A", "Group B", "Group C"), each = 3),
label = c("A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3"),
value = c(10, 15, 25, 20, 10, 30, 40, 20, 15)
)
library(plotly)
labels = c("Group A", "A1", "A2", "A3",
"Group B", "B1", "B2", "B3",
"Group C", "C1", "C2", "C3")
parents = c("", "Group A", "Group A", "Group A",
"", "Group B", "Group B", "Group B",
"", "Group C", "Group C", "Group C")
values = c(0, 10, 15, 25,
0, 20, 10, 30,
0, 40, 20, 15)
fig <- plot_ly(
type="treemap",
labels=labels,
parents=parents,
values = values)
fig
I would like to remove the parent groups (C, B, A)
similar to this chart The Atlas of Economic Complexity
kindly advise.
Hi...
i have tried highcharter but i failed to customized the color according the category and how to create toptip and category name and category value in each tile.
data <- data.frame(
category = rep(c("Group A", "Group B", "Group C"), each = 3),
label = c("A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3"),
value = c(10, 15, 25, 20, 10, 30, 40, 20, 15),
color = rep(c("red", "blue", "green"), each = 3))
dout <- data_to_hierarchical(data, c(category, label), value)
hchart(dout, type = "treemap")