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
0
votes
1 answer

When resizing grobs from a list, getting "Value being assigned must be a unit" error

I'm trying to efficiently resize grobs for making publication quality plots. I'm repeatedly running into the same error in contexts where I'm using code offered in Stack Overflow answers and where that code seems to involve (I think) working with…
neuropsych
  • 305
  • 3
  • 11
0
votes
1 answer

multiplot for gtable objects

The multiplot function is defined here in the cookbook Consider the following graphs. p1 = ggplot(mtcars,aes(y=mpg, x=cyl)) + geom_point() p2 = ggplot(mtcars,aes(y=disp, x=cyl)) + geom_point() multiplot(p1,p2, layout=matrix(1:2,nrow=1)) I'd like…
Remi.b
  • 17,389
  • 28
  • 87
  • 168
0
votes
1 answer

ggplot2 grid_arrange_shared_legend share axis labels

I am using grid_arrange_shared_legend to combine plots with the same legend into one plot with one legend. Is there a way to edit the function slightly so it also shares the x and y axis labels? For example, if I made 3 graphs and wanted a 3x1 grid…
Marissa
  • 345
  • 1
  • 5
  • 17
0
votes
1 answer

Prevent grid.arrange from compressing grobs with autoplot

I use grid.arrange() to plot 4 line charts with one column. The grobs look OK when saving the file as a .png or .pdf, if the dimensions are large. However, when I shrink the height of the plot, the top grob gets compressed. How can I prevent…
derelict
  • 3,657
  • 3
  • 24
  • 29
0
votes
1 answer

marrangeGrob but can't add legends

I used marrangeGrob() instead of facet_wrap() to produce my plots from a list of plots. However, I can't seem to add a legend. I already extracted my legend using g_legend<-function(a.gplot){ tmp <- ggplot_gtable(ggplot_build(a.gplot)) …
Sean Xu
  • 11
  • 1
  • 3
0
votes
0 answers

R code to plot bar plots using ggplot2, Order of Graph, geom_bar

I have categorical variables being passed in the function, and i want the x-lables in multiple lines thus i use a function which i got on the internet called addline_format in scale_x_discrete refer the function below. the problem arises when i have…
0
votes
1 answer

heightDetails does not work with sum of units

I am trying to find out the height of the legend of a ggplot with heightDetails(), but I get the error Error in UseMethod("absolute.units") : no applicable method for 'absolute.units' applied to an object of class "unit" Example: For the…
Hengrui Jiang
  • 861
  • 1
  • 10
  • 23
0
votes
1 answer

Change font size of all existing grobs in table

The following is some example code provided by baptiste which shows how to modify the font size of an individual grob element. g <- tableGrob(iris[1:4, 1:3]) find_cell <- function(table, row, col, name="core-fg"){ l <- table$layout …
Scott
  • 446
  • 4
  • 16
0
votes
0 answers

Title to group facet labels

I'd like to label my facet grid with a title ("ID", as seen below) using the guidelines provided in this post, but I don't understand how to fiddle with the Grob parameters enough to adapt the code to my particular case (not because of lack of…
SilvanD
  • 325
  • 2
  • 14
0
votes
2 answers

Unable to pass textGrob as main to do.call("arrangeGrob")

While test <- do.call("arrangeGrob", c(plots.list[1:2],ncol=2,main=("test")) works just fine, test <- do.call("arrangeGrob", c(plots.list[1:2],ncol=2,main=textGrob("test"))) gives the following error: "Error in arrangeGrob(list(grobs =…
Hengrui Jiang
  • 861
  • 1
  • 10
  • 23
-1
votes
1 answer

How to Change Table Background with tableGrob in GridExtra

I have this Gridmesh in the Background of my plottet table. How do i Change the Background other then with theme https://i.stack.imgur.com/PHpd5.jpg cor.t=mydata tt3 <- ttheme_minimal( base_size = 8, core=list(bg_params = list(fill =…
Alexander Vocaet
  • 188
  • 1
  • 10
1 2 3
9
10