Share the Gallery !Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

 

 

This is a treemap with several levels. We have 3 groups, each containing several subgroups. Each subgroup has a value which we map to an area.

In the index argument, you need to specify levels in the order of importance: group > subgroup > sub-subgroup …

See graph # for a more basic example, and graph # to customize the appearance of the chart.

 


Not what you are looking for ? Make a new search !


Leave a Reply

3 Comments on "#235 Treemap with subgroups"

Notify of
avatar
Sort by:   newest | oldest | most voted
Isadora
Guest

Hi,

is there a way I can put three levels on this treemap?

Holtz
Guest

Hi Isadora,

You can add 3 levels as follow.
However, it becomes hard to read it. Did you think about doing an interactive version?
http://www.r-graph-gallery.com/237-interactive-treemap/

—————–

# library
library(treemap)

# Build Dataset
group=c(rep(“group-1”,6),rep(“group-2”,6))
subgroup=paste(“subgroup” , rep(c(1,1,1,2,2,2),2), sep=”-“)
subsubgroup=paste(“sub-subgroup” , rep(c(1,2,3),4), sep=”-“)
value=c(13,5,22,12,11,7,3,1,23,2,6,14)
data=data.frame(group,subgroup,subsubgroup,value)

# treemap
treemap(data,
index=c(“group”,”subgroup”,”subsubgroup”),
vSize=”value”,
type=”index”
)

Isadora
Guest

Hi
is there a way I can put three levels on this treemap?

wpDiscuz