How to make the output of a treemap bigger?

Viewed 35

I am presenting some cancer datasets on a tree map. The proportions are fine and the data is good, the problem is the output map is too dense, and it's hard to even see. So the problem is only with the output not the data itself. I just need it to be bigger and wider, to be clearer and easier to understand.

Here is the code I'm using (I saw another topic about this question but the solution there did not help me):

png(filename="tree.png",width=800, height=800)

treemap(treeMAP,
        index=c("group","subgroup"),
        vSize="value",
        type="index",
        fontcolor.labels=c("white","black"),
        fontface.labels=c(4,2),
        inflate.labels=F,
        title  = 'Treemap of cancer types',
        palette = "Set2") 

dev.off()

Here is the map:

enter image description here

the treeMAP dataframe:

structure(list(group = c("Melanoma", "Melanoma", "Melanoma", 
"Melanoma", "Melanoma", "Melanoma", "Melanoma", "Melanoma", "Melanoma", 
"Melanoma", "Renal CC Carcinoma", "Renal CC Carcinoma", "Renal CC Carcinoma", 
"Urothelial Carcinoma", "Urothelial Carcinoma", "NSCLC", "NSCLC", 
"Thymic Carcinoma", "Breast"), subgroup = c("subgroup-1", "subgroup-2", 
"subgroup-3", "subgroup-4", "subgroup-5", "subgroup-6", "subgroup-7", 
"subgroup-8", "subgroup-9", "subgroup-10", "subgroup-1", "subgroup-2", 
"subgroup-3", "subgroup-1", "subgroup-2", "subgroup-1", "subgroup-2", 
"subgroup-1", "subgroup-1"), value = c(7, 49, 44, 14, 47, 39, 
25, 53, 38, 119, 181, 356, 165, 298, 21, 25, 16, 9, 12)), class = "data.frame", row.names = c(NA, 
-19L))
1 Answers

When I set the width = 1150 it seems to be showing the labels properly. Here is the code with output:

png(filename="tree.png",width=1150, height=800)
library(treemap)
treemap(treeMAP,
        index=c("group","subgroup"),
        vSize="value",
        type="index",
        fontcolor.labels=c("white","black"),
        fontface.labels=c(4,2),
        inflate.labels=F,
        title  = 'Treemap of cancer types',
        palette = "Set2") 

dev.off()

Output:

enter image description here

As you can see it is much better.

Related