Reputation: 5398
Treemap uses vSize
value to scale the size of each box.
I want to printed the value of the sum amount in the treemap plot label.
Current code:
library(treemap)
treemap(dtf=iris, index="Species", vSize="Sepal.Length")
xtabs(Sepal.Length ~ Species, data = iris)
# Species
# setosa versicolor virginica
# 250.3 296.8 329.4
Upvotes: 3
Views: 3389
Reputation: 5398
Summarize the data and create a new index and label.
library(treemap)
library(dplyr)
iris%>%
group_by(Species)%>%
summarise(Sum.Sepal.Length=sum(Sepal.Length))%>%
mutate(Species.Index=paste(Species, Sum.Sepal.Length, sep ="\n"))%>%
treemap(index="Species.Index", vSize="Sum.Sepal.Length")
Upvotes: 4