gridextra

Locate title in top left of grid.arrange

房东的猫 提交于 2020-05-15 04:18:33
问题 I have two plots arranged side by side with gridExtra::grid.arrange . I can put a title on top of them with the top argument. Problem is, I was requested to locate the title on the top left of the plot. A reproducible example: library(ggplot2) library(gridExtra) p1 <- qplot(1:20) p2 <- qplot(30, 35) grid.arrange(p1, p2, nrow = 1, top = "Title") which produces But what I need is: I read several times the ?arrangeGrob file (I think there lies my answer), but haven't figured out how to achieve

Locate title in top left of grid.arrange

只谈情不闲聊 提交于 2020-05-15 04:18:06
问题 I have two plots arranged side by side with gridExtra::grid.arrange . I can put a title on top of them with the top argument. Problem is, I was requested to locate the title on the top left of the plot. A reproducible example: library(ggplot2) library(gridExtra) p1 <- qplot(1:20) p2 <- qplot(30, 35) grid.arrange(p1, p2, nrow = 1, top = "Title") which produces But what I need is: I read several times the ?arrangeGrob file (I think there lies my answer), but haven't figured out how to achieve

Add a common legend

旧城冷巷雨未停 提交于 2020-01-23 12:17:53
问题 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

add superscript in table using tableGrob

僤鯓⒐⒋嵵緔 提交于 2020-01-15 07:32:25
问题 How to add superscript in table? For instance, the column b of df would indicate the duplicate index as superscript. I could think of introducing the values of column b as expression, but there may be better way of doing it. Data: df <- data.frame( a = 1:6, b = rep( letters[1:3], each = 2 ) ) Code: library( 'gridExtra' ) library( 'grid' ) tg_df <- tableGrob( d = df ) grid.draw( tg_df ) Output: Expected: 回答1: You can do this by creating the appropriate plotmath superscript strings and

Is it possible to crop a plot when doing arrangeGrob?

喜夏-厌秋 提交于 2020-01-14 01:36:27
问题 I have a use-case similar to the following where I create multiple plots and arrange them into some page layout using gridExtra to finally save it as a PDF with ggsave : p1 <- generate_ggplot1(...) p2 <- generate_ggplot2(...) final <- gridExtra::arrangeGrob(p1, p2, ...) ggplot2::ggsave(filename=output.file,plot=final, ...) Is it possible to have plot p2 cropped while arranging it into the page layout with arrangeGrob ? The problem is that p2 has a lot of extra space on the top and bottom of

ggplot list of plots to one pdf with different page layouts

岁酱吖の 提交于 2020-01-13 20:27:27
问题 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?

Rmarkdown: Multiple plots on same page with separate captions

≯℡__Kan透↙ 提交于 2020-01-11 06:43:09
问题 I am writing a report in R markdown with a pdf output. I have several plots and I would like to display four plots per page laid out in a 2x2 matrix. Is there a way to get them to display like that with separate captions? Here is what I have tried so far: Package gridExtra - I can easily setup the layout I want but I wasn't able to add captions to the plots.Is there an option to add captions to the plot in grid.arrange ? Placing each plot in a different chunk and playing with R chunk options.

gtable: Put a black line around all cells in the table body

孤街醉人 提交于 2020-01-05 10:06:13
问题 I'm trying to put a relatively heavy line (say lwd = 2 size) around the body of a table using gridExtra . Here's a MWE slightly modified from this documentation page. gtable is doing the work under the hood but the documentation for gtable is thin; looking at the code didn't help much. g <- tableGrob(iris[1:4, 1:3], rows = NULL) separators <- replicate(1, segmentsGrob(x1 = unit(0,"npc")), simplify=FALSE) g <- gtable::gtable_add_grob(g, grobs = separators, t = 1, b = nrow(g), l = 1) g <-

gtable: Put a black line around all cells in the table body

我是研究僧i 提交于 2020-01-05 10:06:11
问题 I'm trying to put a relatively heavy line (say lwd = 2 size) around the body of a table using gridExtra . Here's a MWE slightly modified from this documentation page. gtable is doing the work under the hood but the documentation for gtable is thin; looking at the code didn't help much. g <- tableGrob(iris[1:4, 1:3], rows = NULL) separators <- replicate(1, segmentsGrob(x1 = unit(0,"npc")), simplify=FALSE) g <- gtable::gtable_add_grob(g, grobs = separators, t = 1, b = nrow(g), l = 1) g <-

R suppressing rownames in grid table

梦想与她 提交于 2020-01-03 07:09:08
问题 I can produce a table with gridExtra: eg: library(gridExtra) grid.table(head(iris)) But this produces a rownames column 1:6. Is there a way to be able to suppress the rownames column so that it does not appear in the table? Thank you for your help. 回答1: Just add rows = NULL : grid.table(head(iris), rows = NULL) Another solution could be setting show.rownames = FALSE grid.table(head(iris), show.rownames = FALSE) 来源: https://stackoverflow.com/questions/15045396/r-suppressing-rownames-in-grid