gridextra

ggplot2 : printing multiple plots in one page with a loop

大兔子大兔子 提交于 2019-12-12 09:45:03
问题 I have several subjects for which I need to generate a plot, as I have many subjects I'd like to have several plots in one page rather than one figure for subject. Here it is what I have done so far: Read txt file with subjects name subjs <- scan ("ListSubjs.txt", what = "") Create a list to hold plot objects pltList <- list() for(s in 1:length(subjs)) { setwd(file.path("C:/Users/", subjs[[s]])) #load subj directory ifile=paste("Co","data.txt",sep="",collapse=NULL) #Read subj file dat = read

Plotting quantile regression by variables in a single page

早过忘川 提交于 2019-12-11 07:39:59
问题 I am running quantile regressions for several independent variables separately (same dependent). I want to plot only the slope estimates over several quantiles of each variable in a single plot. Here's a toy data: set.seed(1988) y <- rnorm(50, 5, 3) x1 <- rnorm(50, 3, 1) x2 <- rnorm(50, 1, 0.5) # Running Quantile Regression require(quantreg) fit1 <- summary(rq(y~x1, tau=1:9/10), se="boot") fit2 <- summary(rq(y~x2, tau=1:9/10), se="boot") I want to plot only the slope estimates over quantiles.

R: gridExtra - How to plot a Summary as table?

不羁的心 提交于 2019-12-11 04:09:43
问题 I'm having trouble plotting a simple summary. library(gridExtra) SummaryTable <- summary(s.tvs$precio.nuevo) grid.table(SummaryTable) Gives me this: I want to achieve something like this: 回答1: Upgrade comment: grid.table calls tableGrob . grid.table #function (...) #grid.draw(tableGrob(...)) #<environment: namespace:gridExtra> From ?tableGrob its first argument is a matrix or data.frame. t coerces the named vector returned by summary to a matrix with dimension one row. Alternatively, you

positioning plots and table

本小妞迷上赌 提交于 2019-12-11 03:44:50
问题 I would like to plot two histograms and add a table to a pdf file. With the layout function I managed to plot the histograms (plotted them using hist function) where I want them to be but when I used grid.table function from the gridExtra package to add the table the table is laid out on the histograms and I am not able to position them properly. I have tried addtable2plot function but I dont find it visually appealing. Any thoughts on How do I get around this? I want my pdf to look like this

remove the borders from grid.arrange

拈花ヽ惹草 提交于 2019-12-10 20:07:29
问题 I am combining multip ggplot graphs using gridExtra package grid.arrange function. I doing this: p1<-ggplot(x, aes(Date, Value)) + geom_line() p2<-ggplot(y, aes(Date, Score)) + geom_point() grid.arrange(p1, p2, main=textGrob("Head Line", gp=gpar(cex=1.5, fontface="bold", col="#990000")), ncol = 1, clip=TRUE) this command puts border between p1 and p2. I couldn't find any info on removeing the borders in grid.arrange. Is it possible to remove the borders? 回答1: gridExtra doesn't put any

Cannot disable R markdown output from gridExtra (additional comment)

Deadly 提交于 2019-12-10 17:50:29
问题 In my r markdown report i use 2 chunks. First: ```{r, include = FALSE, echo=FALSE, results='asis'}``` Where i load all packages and do computation. And second {r, fig.margin = TRUE, fig.width=10, fig.height=4.5, echo=FALSE, results='asis', message=FALSE, warning = FALSE} Where i have for loop where I filter data I producent in first chunk, and make ggplots for each i. My problem is that, when i produce 2 plots in second chunk i combine them in one grid by grid.arrange, but there is additional

How do I customize particular columns for a tableGrob in R?

不羁的心 提交于 2019-12-10 14:55:17
问题 I'm looking to customise particular columns in my tableGrob, for this reproducible example I have chosen to look at customising justification. Say you have the following dataframe: df <- data.frame(Order = c(1:3), Name = c("Adam", "Ben", "Charlie"), Score = c(4, 8, 9)) And you want to use the package gridExtra to present the table: dfGrob <- tableGrob(df, rows = NULL) grid.arrange(dfGrob) You can adjust the alignment of the columns by adjusting the theme used to build the grob, for example:

GridExtra: Align text to right

为君一笑 提交于 2019-12-10 14:35:30
问题 I'm using gridExtra package of R. I'd like to align the numbers of the second column to the left, without changing the alignment of the names of first column. Is it possible? Thank you! library(gridExtra) library(grid) names=c("name1","name2","name3","long name","very long name") values1=c(100000000,70000,20,600000000000000000,500) values1=format(values1,big.mark=".",decimal.mark=",",scientific=FALSE) d=data.frame(names=names,values1=values1) g1 <- tableGrob(d) grid.newpage() grid.draw(g1)

How to adjust the Font Size of tableGrob

南楼画角 提交于 2019-12-09 07:57:00
问题 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. 回答1: 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

How to have a clickable picture in a PDF created using pictureGrob?

◇◆丶佛笑我妖孽 提交于 2019-12-08 12:04:32
问题 I create a simple plot and have a picture actually an SVG icon as follows: library(ggplot2); library(grid); library(gridExtra) facebookGrob <- gTree(children=gList(pictureGrob(readPicture("inst/svg/facebook2.svg")))) p1 <- ggplot() + ggplot2::annotation_custom(facebookGrob, xmin=1.8, xmax=3.2, ymin=-0.6, ymax=1) final <- arrangeGrob(p1,...,) ggsave(filename='output.pdf',plot=final,...) Is there any way to generate a clickable link on top of this SVG icon in the final PDF? 回答1: the tikzDevice