The below code uses just one parameter label_size, but given that the actual data that I will use will contain short and (very) long names, I wonder if it is possible to make the labels as large as possible within each pane and − if that becomes too small for legibility − to have a leader line point to a label next to the chart. I would already be quite happy with only the first. In the image below you see that the Dodge Challenger and Lincoln Continental labels could use a bigger sized font.
library(WeightedTreemaps)
# load example data
data(mtcars)
mtcars$car_name = gsub(" ", "\n", row.names(mtcars))
# generate treemap; set seed to obtain same pattern every time
tm <- voronoiTreemap(
data = mtcars,
levels = c("gear", "car_name"),
cell_size = "wt",
shape = "rounded_rect",
seed = 123
)
drawTreemap(tm, label_size = 2.5, label_color = "white")
