Search code examples
rtreemap

How do I resize the treemap output in R


I'm using Martijn Tennekes's treemap package (version 2.2) in R (version 3.1.2) using RStudio (version 0.98.1091). It's working great but there's one thing I'd like to do - resize the output.

My call looks like this:

treemap(xlFile, 
        index=c("Code1", "Code2"), 
        vSize="size", 
        vColor="ID", 
        type="value", 
        fontsize.labels=c(14,7))

It generates a very small treemap. The aspect ratio is fine (and changing that parameter doesn't change the output dimensions).

I would just like to make the whole treemap output larger. The documentation says the treemap can be zoomed in/out, but I'm not sure that'll help - I want to change the output file, not just the view.

Thank you. John


Solution

  • You can set the width and height of your graphical device. You could for example do:

    png(filename="tree.png",width=800, height=800)
    treemap(xlFile, 
            index=c("Code1", "Code2"), 
            vSize="size", 
            vColor="ID", 
            type="value", 
            fontsize.labels=c(14,7))
    dev.off()
    

    You can look at this page if you want the output in another format or if you want to look at more options.