Questions tagged [r-grid]

grid is an R package providing low-level plotting facilities.

grid is an package providing low-level ting facilities.

Repositories

Vignettes

  • Vignettes for this package are not available online. Use browseVignettes() or vignette(package = "grid") to access them.

Books

Other resources

Related tags

Unrelated tags

341 questions
6
votes
4 answers

Multicolored title with R

I'd like to add colors to certain words in titles to my graphs. I've been able to find some precedent here. Specifically, I'd like the text that's wrapped in apostrophes (in the output, below) to correspond to the color of their respective bar…
Dan Kalleward
  • 183
  • 1
  • 8
6
votes
1 answer

Add title below the graph with four plots in ggplot

Due to the privacy of the data, I use mtcar dataset in ggplot2 to explain my question. There are four plots: g1 <- ggplot(mtcars,aes(mpg,wt)) + geom_point() g2 <- ggplot(mtcars,aes(mpg,disp)) + geom_point() g3 <- ggplot(mtcars,aes(mpg,drat)) +…
Ling Zhang
  • 281
  • 1
  • 3
  • 13
6
votes
2 answers

Background of grid.arrange

I have made a plot like the one described by the code below resulting in the posted image. I can not figure out how to set the entire background to the same "grey80"-color I have used when defining the subplots. Ie. I want to color the white areas…
Gabra
  • 745
  • 8
  • 12
6
votes
1 answer

Align discrete and continuous axes with ggplot2 and grid

I'm attempting to display a grid figure of summarized weekly data of several variables. The two components of this graph that are most pertinent are a distributional summary graph (so box plot or violin plot) of the values that a certain variables…
Dalton Hance
  • 244
  • 1
  • 9
6
votes
1 answer

why ncol option does not work in my facet_grid in R

I am trying to learn ggplot with facet. here is the codes works in Rstudio p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() # With one variable p + facet_grid(. ~ cyl) however, it shows error for ncol after I added ncol=2 : p + facet_grid( ~…
czqiu
  • 291
  • 1
  • 3
  • 7
6
votes
1 answer

How to use R base plots in grid.newpage?

Is it possible to "force" R base plots in grid package's grid.newpage? For example, this works fine: library(grid) grid.newpage() vp1 <- viewport(x=0,y=0.5,width=0.5, height=0.5, just = c("left", "bottom")) vp2 <- viewport(x=0.5,y=0,width=0.5,…
Mikko
  • 7,530
  • 8
  • 55
  • 92
5
votes
2 answers

rotate labels in grid.xaxis

It doesn't seem to be possible to rotate the labels of an xaxis using grid.xaxis(at=, lab=) by e.g. 90 degrees using a gpar-option. Anybody knows a workaround apart from creating separate viewports and using grid.text()?
user1142774
  • 51
  • 1
  • 2
5
votes
2 answers

Question on how to draw back-to-back plot using R and ggplot2

I aiming to draw a pyramid plot, like the one attached. I found several example using ggplot, but I am still struggling with the adoption of my example to my data (or the data that I want to plot). structure(list(serial = c(40051004, 16160610,…
Rfanatic
  • 2,224
  • 1
  • 5
  • 21
5
votes
2 answers

How to lengthen specific tick marks in facet gridded ggplot?

I want longer tick marks for those with labels in a facet grid. So I worked through this attempt and tried to adapt it to facet gridded plots like so: Defining breaks and labels, minor and major: range.f <- range(unique(df1$weeks)) minor.f <- 1 #…
jay.sf
  • 60,139
  • 8
  • 53
  • 110
5
votes
2 answers

Bar charts connected by lines / How to connect two graphs arranged with grid.arrange in R / ggplot2

At Facebook research, I found these beautiful bar charts which are connected by lines to indicate rank changes: https://research.fb.com/do-jobs-run-in-families/ I would like to create them using ggplot2. The bar-chart-part was…
Ben
  • 197
  • 1
  • 9
5
votes
1 answer

Join images with data frames in r

This is probably a very basic question, but I am not familiar with images in R. I want a PDF file with two joined imported images and a data frame as the image exemplifies: This is the code that I am using but is not…
Ushuaia81
  • 495
  • 1
  • 6
  • 14
5
votes
1 answer

Draw multiple object of class tmap with just one common legend

I am trying to draw multiple maps from the tmap-package using tm_shape() and tm_layout() in one page using grid.layout() from the grid-package. I would like to plot only one common legend for all maps, similar to the example shown here: ggplot…
Erich
  • 93
  • 1
  • 6
5
votes
2 answers

Output Venn gList object and Network plot side-by-side

How can we plot Network plot (igraph package plot) and Venn diagram (VennDiagram gList object) side-by-side in one PDF page? Tried to follow below solutions, didn't work: Plot gList side by side Plot 2 tmap objects side-by-side Side-by-side Venn…
zx8754
  • 52,746
  • 12
  • 114
  • 209
5
votes
2 answers

Add tick marks to facet plots in R

I wish to add tick marks to facet plots. For instance, to a facet plot like this: require(ggplot2) p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_minimal() + geom_hline(yintercept=10, linetype="solid") + …
R. Joe
  • 367
  • 5
  • 13
5
votes
2 answers

Assign unique width to each row of a facet_grid / facet_wrap plot

I'm looking to assign a custom width to each row of a one column, facet-wrapped plot in R. (I know this is entirely non-standard.) With grid.arrange I can assign a unique height to each row of a facet-wrapped like plot with the following…
duhaime
  • 25,611
  • 17
  • 169
  • 224