gridextra

grid.arrange from gridExtras exiting with “only 'grobs' allowed in 'gList'” after update

时光毁灭记忆、已成空白 提交于 2019-12-03 22:05:37
I just updated R, R Studio, and a bunch of packages including ggplot2 and gridExtras on my Mac. Now gridExtras is failing in basic plotting with the error: "only 'grobs' allowed in "gList"" Here's some code that should work but does not: library(ggplot2) p1 = qplot(1:10,rnorm(10)) p2 = qplot(1:10,rnorm(10)) library(gridExtra) grid.arrange(p1, p2, ncol=2, main = "Main title") This dumps out the following error: Error in gList(list(grobs = list(list(x = 0.5, y = 0.5, width = 1, height = 1, : only 'grobs' allowed in "gList" In addition: Warning message: In grob$wrapvp <- vp : Coercing LHS to a

ggplot2 and gridExtra: completely remove strip in facet_grid - not just invisible

天大地大妈咪最大 提交于 2019-12-03 19:48:14
问题 I have two graphs that I'm placing one above the other, in the following way: library(ggplot2) library(gridExtra) p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p2 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p2 <- p2 + facet_grid(cyl ~ .) grid.arrange(p1, p2, ncol=1) For this I need the x axes of the top and bottom graphs to line up, however because of the strip to the left, the faceted graph is narrower than the top graph. I can make the strip invisible using: theme(strip.text.y =

How to adjust the Font Size of tableGrob

拜拜、爱过 提交于 2019-12-03 10:07:23
Any idea how to adjust the font size of a tableGrob? I am using gridExtra 2.0.0, which seem to be very different previous version 0.9.3. g <- tableGrob(mtcars) grid.arrange(g) I am looking to adjust the font size of the text in the table, header, and rowname as well. You can do this via themes: mytheme <- gridExtra::ttheme_default( core = list(fg_params=list(cex = 2.0)), colhead = list(fg_params=list(cex = 1.0)), rowhead = list(fg_params=list(cex = 1.0))) myt <- gridExtra::tableGrob(mtcars[1:5, 1:5], theme = mytheme) grid.draw(myt) There are a number of other examples in browseVignettes(

R - how to allocate screen space to complex ggplot images

妖精的绣舞 提交于 2019-12-03 06:08:45
I am trying to write a script that produces four different plots in a single image. Specifically, I want to recreate this graphic as closely as possible: My current script produces four plots similar to these but I cannot figure out how to allocate screen real-estate accordingly. I want to: modify the height and width of the plots so that all four have uniform width, one is substantially taller than the others which have uniform height among them define the position of the legends by coordinates so that I can use screen space effectively modify the overall shape of my image explicitly as

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

ⅰ亾dé卋堺 提交于 2019-12-02 16:43:29
问题 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 to perform: # the table dt1 <- data.table(parkName=rep(c("Zone A","Zone B", "Zone C" , "Zone D"),5), boundary=rep(0:1,10),v=1:20, w=rnorm(20))[] # criteria for subsetting the table dt2 <- data.table(zone1 = c("Zone A","Zone B"), zone2 =c("Zone B",

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

拟墨画扇 提交于 2019-12-02 09:03:06
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 to perform: # the table dt1 <- data.table(parkName=rep(c("Zone A","Zone B", "Zone C" , "Zone D"),5), boundary=rep(0:1,10),v=1:20, w=rnorm(20))[] # criteria for subsetting the table dt2 <- data.table(zone1 = c("Zone A","Zone B"), zone2 =c("Zone B","Zone C")) # function for subsetting the table and plotting p <- function(sd1,sd2){ dlist <- dt1[parkName=

Combining grid_arrange_shared_legend() and facet_wrap_labeller() in R

强颜欢笑 提交于 2019-12-02 05:20:11
问题 I am trying to combine grid_arrange_shared_legend() and facet_wrap_labeller() in R. More specifically, I want to draw a figure including two ggplot figures with multiple panels each and have a common legend. I further want to italicize part of the facet strip labels. The former is possible with the grid_arrange_shared_legend() function introduced here, and the latter can be achieved with the facet_wrap_labeller() function here. However, I have not been successful in combining the two. Here's

Customizing font colour of one column for a tableGrob in R?

自作多情 提交于 2019-12-02 01:09:37
问题 I would like to customise the font colour of one particular column in my tableGrob. Here is the original table, and this is what I would like the table to look like with the zeros in the fifth column changed to "white" I have followed baptise's instructions here: How do I customize particular columns for a tableGrob in R? with no success. Here is my simple dataframe: count <- data.frame("day17" = c(17, 4, 4, 4, 3, 2), "day27" = c(27, 4, 5, 5, 5, 1), "day37" = c(37, 5, 5, 4, 4, 3), "day47" = c

Combining grid_arrange_shared_legend() and facet_wrap_labeller() in R

可紊 提交于 2019-12-02 01:06:14
I am trying to combine grid_arrange_shared_legend() and facet_wrap_labeller() in R. More specifically, I want to draw a figure including two ggplot figures with multiple panels each and have a common legend. I further want to italicize part of the facet strip labels. The former is possible with the grid_arrange_shared_legend() function introduced here , and the latter can be achieved with the facet_wrap_labeller() function here . However, I have not been successful in combining the two. Here's an example. library("ggplot2") set.seed(1) d <- data.frame( f1 = rep(LETTERS[1:3], each = 100), f2 =

Multiple plots on one page using ggplot

坚强是说给别人听的谎言 提交于 2019-12-01 22:47:27
问题 I have 12 plots generated by a loop and I want to plot them with 3 rows and 2 columns on one page (2 pages in total). I know how to do it in R pdf("1.pdf") par(mfrow = c(3, 2)) for (i in 1:12) { x <- 1:10 y <- 2*x + rnorm(x) plot(x, y) } dev.off() But how to do this using ggplot ? library(ggplot2) library(grid) library(gridExtra) for (i in 1:12) { x <- 1:10 y <- 2*x + rnorm(x) qplot(x, y) } I think I have to use grid.arrange but need some help on that. Thanks. 回答1: You might want to take a