I am placing multiple treemaps inside their own viewport. I specify the viewport of certain size and then add the treemap to the viewport, however I can not get the treemap to fill the entire viewport.
Here is a sample code of what I am trying to do:
library(treemap)
library(grid)
main_vp <- viewport(x=0.5, y=0.5, width=1, height=1)
pushViewport(main_vp)
coords <- data.frame(X=c(0.2, 0.2, 0.5, 0.5), Y=c(0.2, 0.5, 0.5, 0.2))
for(i in 1:4)
{
size <- 0.5
my_x <- coords$X[i]
my_y <- coords$Y[i]
sub_vp <- viewport(x=my_x, y=my_y, width=size, height=size)
pushViewport(sub_vp)
grid.rect(gp=gpar(lty="dashed"), vp=main_vp)
treemap(iris, index=c("Species"), vSize="Sepal.Length", vColor="Species",
title = "", vp=main_vp)
upViewport()
upViewport()
upViewport()
}
If you execute the provided code, you will see that the treemap is very small with respect to the size of the sub viewport and I would like the treemap to cover the maximum area posible in the sub viewport. Any suggestions or examples, Thanks