r - How to plot grid plots on a same page? -



r - How to plot grid plots on a same page? -

i using bundle (treemap) uses grid bundle produce treemap. however, plot several of these treemaps together, add together different color schemes these plots. tmplot function uses grid.newpage function, clears graphics window. have not found way save grid.newpage objects can ggplot2objects. there way plot several grid.newpage objects same window?

## illustration library(treemap) # load gross national income info data(gni2010) size <- aggregate(gni ~ continent, gni2010, sum) size <- size[with(size, order(gni, decreasing = t)),] cont <- size$continent widths <- c(sum(size[c(1,3,5),]$gni), sum(size$gni) - sum(size[c(1,3,5),]$gni)) heights <- c(sum(size[c(1,2),]$gni), sum(size[c(3,4),]$gni), sum(size[c(5,6),]$gni)) palettes <- c("greens", "blues", "reds", "oranges", "purples", "greys") <- 1 # replaced loop x <- subset(gni2010, continent == cont[i], cex = 5) # create treemap layout(matrix(1:6, 3, byrow = true), widths = widths, heights = heights) x1 <- tmplot(x, index=c("iso3"), vsize="population", vcolor="gni", type="value", title = "", position.legend = "none", palette = palettes[i]) grid.text(cont[i], 0.5, 0.5, gp=gpar(fontsize=20, font = 2, col = "white")) ## x1 not create plot such , tmplot overwrites layout

i understand solution scale plots based on gni sum not right. might create question later, 1 time figure out how plot these treemaps in same window.

edit: think reply question "no". cannot save grid.newpage objects name, neither can save several of these on page, because function "erases current device or moves new page" said in description. however, possible find work arounds. tmplot bundle not (as of 23 march, 2013) back upwards viewports, development version does.

thanks question. output of tmplot indeed not saved plot.

in next update add together argument vp, viewport can specified draw in. if not specified, grid.newpage called.

update: check , test development version @ https://github.com/mtennekes/treemap

to apply illustration of bryan hanson:

vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y) grid.newpage() pushviewport(viewport(layout = grid.layout(1, 2))) tmplot(gni2010, index="continent", vsize="population", vcolor="gni", type="value", vp = vplayout(1,1)) tmplot(gni2010, index=c("continent", "iso3"), vsize="population", vcolor="gni", type="value", vp = vplayout(1,2))

r plot treemap r-grid

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -