gridextra

Has anyone else noticed that tableGrob is slow?

冷暖自知 提交于 2019-12-08 08:34:45
问题 I'm plotting database performance data, mostly with ggplot2. There are 8 pages of relatively complex plots and 2 pages of tableGrobs. I just instrumented my code to figure out where I'm spending time and out of 25 seconds total, 13 of those seconds are on the last 2 pages which are the tableGrobs. That 25 seconds includes loading the data, doing serious parsing with stringR, etc. Here's the example output: https://www.dropbox.com/s/3s6bi70py5pgpdm/PSPROD-259-341-1-plot.pdf , though the last

How to draw a box/border around plots arranged side by side using grid.arrange in R

£可爱£侵袭症+ 提交于 2019-12-07 17:43:41
问题 I have created two plots using ggplot as follows: library(ggplot2) library(gridExtra) g1 <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point() g2 <- ggplot(iris, aes(Petal.Width, Petal.Length)) + geom_point() grid.arrange(g1, g2, ncol=2) I would like to draw a border/box around the two side by side plots produced by grid.arrange...I think it is something to do with using grid.border, but am not sure of how exactly to do so. Will appreciate any help? 回答1: Using an example from the

how do I get rid of random background grid from arrangeGrob

房东的猫 提交于 2019-12-07 13:41:43
问题 I need to wrap several plots in a grid, often an uneven number, so there'll often be an "empty spot" . I need to use arrangeGrob() -- not grid.arrange() -- because I want to save the plot for later, not plot() it right away. This works fine, but oddly, arrangeGrob() leaves some weird background in the empty spots. Like so: library(ggplot2) p1 <- ggplot(mtcars, aes(x=factor(cyl), y=mpg)) + geom_boxplot() p2 <- ggplot(mtcars, aes(x=factor(cyl), y=wt)) + geom_boxplot() p3 <- ggplot(mtcars, aes(x

How to arrange html widget plots in a grid for export as pdf?

此生再无相见时 提交于 2019-12-07 11:58:28
问题 I would like to combine the richness of html widgets (mainly plotly and networkD3), with the possibility of arranging them as plots in a grid in R, to export them as pdf graphic for a publication. However, if I create some html widget objects in R and try to arrange them with gridExtra::grid.arrange() (see minimal example below) I get the following error: Error in gList(list(x = list(links = list(source = c(0, 0), target = c(1, : only 'grobs' allowed in "gList" I searched for “converting html

marrangeGrob giving error for nrow

醉酒当歌 提交于 2019-12-07 09:30:07
问题 I'm trying to create a bunch of ggplot2 plots using a for loop and then saving them on a multi-page pdf document, and I'm having trouble with marrangeGrob. Here's some example code: Plots <- list() Plots[[1]] <- qplot(mtcars$mpg, mtcars$wt) Plots[[2]] <- qplot(mtcars$cyl, mtcars$wt) Plots[[3]] <- qplot(mtcars$mpg, mtcars$qsec) Plots[[4]] <- qplot(mtcars$cyl, mtcars$drat) # install.packages("gridExtra", dependencies = TRUE) library(gridExtra) MyPlots <- do.call(marrangeGrob, c(Plots, nrow = 1,

Add a common legend

筅森魡賤 提交于 2019-12-06 12:32:13
I was trying to do a multiplot with ggplot2 . This was my initial code nucmer_s1 <- ggarrange(eight_uniform, ten_uniform, twelve_uniform, fourteen_uniform, sixteen_uniform, ncol=3, nrow=2, common.legend = TRUE, legend="bottom") getting this error Error in plot$scales : $ operator is invalid for atomic vectors then. annotate_figure(nucmer_s1, top = text_grob("Genomas validados con distribución de datos equilibrada", color = "black", face = "bold", size = 12)) however I obtain the graphic But I need to put a title in the each plot a title so I changed to this one nucmer_s1 <-grid.arrange( eight

How to put a wordcloud in a grob?

旧街凉风 提交于 2019-12-06 12:13:13
问题 I've created a simple wordcloud: require(wordcloud) words <- c('affectionate', 'ambitious', 'anxious', 'articulate', 'artistic', 'caring', 'contented', 'creative', 'cynical', 'daring', 'dependable', 'easygoing', 'energetic', 'funny', 'generous', 'genuine', 'goodlistener', 'goodtalker', 'happy', 'hardworking', 'humerous', 'impulsive', 'intelligent', 'kind', 'loyal', 'modest', 'optimistic', 'outgoing', 'outrageous', 'passionate', 'perceptive', 'physicallyfit', 'quiet', 'rational', 'respectful',

ggplot list of plots to one pdf with different page layouts

馋奶兔 提交于 2019-12-06 11:30:06
I want to produce a single pdf with many pages of ggplots. Using gridExtra , I can also build a page of plots with a m x n layout ( m rows of plots, n columns of plots). The function ggsave allows me to write a page of plots, even those that are built with gridExtra having the m x n layout. Using arrangeGrob it is even possible to ggsave many pages to a single pdf, as long as each page has the same m x n layout. I'm wondering how I can ggsave a list of plots that have different page layouts? For example, I have a list, l , with length 3 representing 3 pages. l[[1]] is a page with a 2 x 2

plotting a list of grobs

百般思念 提交于 2019-12-06 08:50:45
问题 DISCLOSURE: I'm not sure how to make a reproducible example for this question. I'm trying to plot a list of grobs using the gridExtra package. I have some code that looks like this: ## Make Graphic Objects for Spec and raw traces for (i in 1:length(morletPlots)){ gridplots_Spec[[i]]=ggplotGrob(morletPlots[[i]]) gridplots_Raw[[i]]=ggplotGrob(rawPlot[[i]]) gridplots_Raw[[i]]$widths=gridplots_Spec[[i]]$widths } names(gridplots_Spec)=names(morletPlots) names(gridplots_Raw)=names(rawPlot) ##

In R, how can I store an inset graph for later arranging it with grid.arrange?

此生再无相见时 提交于 2019-12-06 07:27:46
问题 I have created a graph in which I inset another graph (both ggplot2 objects) via this command: vp=viewPort(...) print(ggplotobject1) print(ggplotobject2, vp=vp) This works exactly how I'd like it to (one large graph with a custom small graph drawn in the area specified in viewPort). The problem is that I need to use this combined graph later for arranging it with other plots again through: grid.arrange(arrangeGrob(..)) Does anyone have an idea how I can store my combined graph as a grob?