Questions tagged [grob]

stands for **gr**aphical **ob**ject, the generic drawing component in the grid framework of R graphics. Grobs can be very primitive, such as text, rectangles, lines, or complex objects such as full plots built up from many lower-level components.

The recommended grid package is included in every distribution of the R software. As such, it provides a low-level framework for building up all kinds of static graphics. The core component of grid-based graphics is a grob, which in its most basic form is a generic class of objects that describe a graphical component. The most basic grobs are simple shapes such as pointsGrob, polygonGrob, etc., but new objects can be derived from those primitive objects, and are often assembled into a grob tree, or gTree, which holds together multiple shapes together with a specific layout.

Examples of high-level, complex grobs are the complete plots generated by the ggplot2 and lattice packages.

146 questions
4
votes
1 answer

Universal x axis label and legend at bottom using grid.arrange

I am trying to plot a number of graphs next to each other using grid.arrange. Specifically, I would like the plots to have a shared x axis label and a legend at the bottom. Here is the code I am using for the arrangement (working example here), sans…
simoncolumbus
  • 526
  • 1
  • 8
  • 23
3
votes
1 answer

Left-aligning ggplot when saved while using a fixed aspect ratio

I'm building a custom ggplot theme to standardize the look & feel of graphs I produce. The goal is more complex than this minimal example, so I'm looking for a general solution. I have a few key goals: I want all graphs to export at the same size…
Michael Toth
  • 75
  • 10
3
votes
1 answer

How to align ggparagraph() text under tableGrob() in R

What I want to achieve I am trying to implement margins in the ggparagraph(), but I can't find any settings which would help out. I tried setting both widths the same in ggarrange(), but this did not work and is a workaround. What would happen now…
PLY
  • 531
  • 2
  • 4
  • 18
3
votes
1 answer

horizontal connectGrobs don't always connect to the edge of the boxGrob

I was running the example here, and noticed that the horizontal arrow connecting the Total to the Ineligible boxGrobs doesn't always touch the left-edge of the the Ineligible boxGrob. It seems to depend on the width of the viewing window in RStudio.…
morgan121
  • 2,213
  • 1
  • 15
  • 33
3
votes
1 answer

Combining two grobs , one of them created using grid.draw

I am trying to combine two graphical objects (grob) to a single plot - one of them created with "standard ggplot()" call, the other using grid.draw() on a ggplot_gtable object (based on this…
tjebo
  • 21,977
  • 7
  • 58
  • 94
3
votes
1 answer

R graphics: How to make objects from VennDiagram compatible with cowplot plot_grid?

I am making Venn diagrams with the VennDiagram package. They are coming out OK: library(VennDiagram) library(cowplot) png("p.png") p = draw.pairwise.venn(30,20,11, category = c("Dogs", "Cats"), lty = rep("blank", 2), fill = c("light blue",…
phlatphish
  • 95
  • 5
3
votes
1 answer

How to change color to a textGrob item

I am trying to change the background color of my title. I have followed this code which results to adding a title on top of my tableGrob. However, the fill option is not enabled. No warning or error posted in R (v3.2.5). d <- head(iris[,1:2]) table…
KRStam
  • 393
  • 5
  • 18
3
votes
1 answer

Multiple plots side by side - How to make all plots the same widths?

I am just arranging three ggplots so that they appear side by side in the saved png. Thereby I followed the helpful clue of this answer. For better clearness I display only the legend of the rightmost plot. Logically now there has to be specified a…
jay.sf
  • 60,139
  • 8
  • 53
  • 110
3
votes
1 answer

Add an arrow pointing at the x-axis in my plot in ggplot2

My goal is to get an arrow with a text pointing at my x-axis to label the average word frequency. I cannot figure out for the life of me how to get either an arrow or a text outside of the plotting area in ggplot2. Here is my code:…
Devon
  • 61
  • 4
3
votes
1 answer

Using directlabels::geom_dl when label is the same for two groups

I have a problem with geom_dl() where it is not placing my label correctly because two groups have the same label. I can see that data$groups <- data$label inside of the GeomDl call is causing the trouble, but I can't figure out how to fix it. This…
fishgal64
  • 94
  • 7
3
votes
1 answer

Add multiple curves between ggplot2 plots

I have two ggplot2 plots and I want to draw a series (10-100) slightly different curves between them. That is, I will have a two-panel layout and want to draw connecting lines from the left plot to the right plot. So far I have tried doing this by…
user1356855
  • 565
  • 2
  • 5
  • 11
3
votes
1 answer

problems with arrangeGrob under R version 3.2.2

I 've updated my R version including all packages and the function arrangeGrob (Package gridExtra) has changed. On my old version R version 3.1.3 I used it as the following to make corner labels: loading r…
Kev
  • 425
  • 3
  • 8
3
votes
1 answer

R ggplot2: annotation_custom of raster grob does not plot

UPDATE Turns out it was an issue of not being able to produce raster graphics over a remote desktop connection. I want to insert an image from file into a plot made with ggplot2. This question has already been asked here (Inserting an image to…
nelliott
  • 123
  • 8
2
votes
2 answers

Problem with cowplot in R: when paneling grobs and exporting as pdf, bullets turn into ellipses

I have a rather peculiar problem in paneling with cowplot and exporting the result as a PDF file. Consider the following MWE: # Load libraries library(consort) library(cowplot) library(ggplotify) # Create data for flowchart A participant_id <-…
jaggedjava
  • 440
  • 6
  • 14
2
votes
1 answer

Programmatically position image on ggplot using annotation_custom

I am trying to create a function (inside an R package) that adds an image to the lower right corner of a ggplot. Since this will be included in a R package, I want this function to programmatically position this image to the bottom right of the…
Howard Baek
  • 186
  • 10
1 2
3
9 10