FAQ Database Discussion Community


Use ggplot2 and tablegrob to plot grouped boxplots with summary statistics from multiple matrices with NA values

r,table,ggplot2,gridextra
I've searched around for a while but I still can't solve this minor issue in which I would like to change the decimal place of numbers in the table created by tablegrob(). Doing so would make the entire view look better, as seen below: This is the code: a<-as.vector(matrixA) #matrices...

R, mapply , ggplot : EXPR must be a length 1 vector

r,ggplot2,gridextra,mapply
I am trying plot the subsets of a table using ggplot and gridExtra. But I have bumbed in the following error EXPR must be a length 1 vector. I could come up with any side step. Any help would be useful. Here is a little example of what I'm trying...

Store output from gridExtra::grid.arrange into an object

r,ggplot2,gridextra
I am placing multiple plots into one image using gridExtra::grid.arrange and would like to have the option of saving the combined plot as an object that could be returned from within a function as part of a list of returned objects. Ideally, I would like to do this without printing...

How to arrange one grob object inside another with ggplot2 and gridExtra packages in r

r,ggplot2,gridextra
I would like to know how to arrange one grob object (a table) inside another. Consider the following example: library(ggplot2) library(gridExtra) p1 <- qplot(data=mtcars, x = mpg, y = hp, facets = ~ hp, geom="point") t1 <- tableGrob(head(mtcars)) print(arrangeGrob(p1, t1)) This yields: What I would like to do is place...

How to theme a tableGrob object from gridExtra in r

r,gridextra,grob
I would like to re-use a theme/template/default for a tableGrob object from the gridExtra package in r. library(gridExtra) tableGrob(df, cols = c("Custom Name", "Custom Name2"), show.rownames = FALSE, h.even.alpha = 0) tableGrob(df2, cols = c("Different Name", "Different Name2"), show.rownames = FALSE, h.even.alpha = 0) Notice, I do not want to...

ggplot2 and gridExtra: reduce spacing among plots that have facet strips removed

r,ggplot2,spacing,gridextra
I wish to plot a number of tightly spaced graphs as illustrated by the following toy example: library(ggplot2) library(gridExtra) set.seed(314159) n <- 100 data <- data.frame(x = rnorm(n), y = rnorm(n), z = rep("dummy var", n)) p00 <- ggplot(data, aes(x)) + stat_density() + theme(plot.margin = unit(c(0,0,0,0), units = "lines" ),...

Adjust space between gridded, same-sized ggplot2 figures

r,ggplot2,gridextra
I am attempting to arrange multiple ggplot2 plots into one output/grid. I'd like the plots (without considering the labels) to be the same size. I have found a way to do this, but now I'd like to adjust the space between the plots. For example: In this plot, I'd like...

splitting or removing graphs after arrangeGrob

r,ggplot2,gridextra
I created a graph with ggplot and later I used arrangeGrob to combine those graphs. Is there a way to remove parts a graph from this combined plot? Or maybe extract? Here is a minimal example: library(ggplot2) library(gridExtra) df <- data.frame(x=rnorm(20), y=rnorm(20), y2=rnorm(20)) g1 <- ggplot(df, aes(x, y)) + geom_point()...