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

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With