How does `ggplotGrob` work?

11,067

ggplotGrob is the same as ggplot_gtable(ggplot_build(x)); it's just a convenience function to save some typing.

The end goal is to convert the ggplot object, which is essentially a list describing how to build the plot, into a gtable, which is a grid graphical object (grob) that can be drawn on a device. So if what you're after is altering the output of ggplotGrob to change the layout or add graphical components to it, you should look into the gtable package.

Share:
11,067

Related videos on Youtube

Remi.b
Author by

Remi.b

Updated on September 14, 2022

Comments

  • Remi.b
    Remi.b over 1 year

    docs.ggplot2.org currently offers very little documentation for the function ggplotGrob. The EPFL website is a little bit more informative but it is still not very helpful.

    Can you please provide a short tutorial on what one can do with the function ggplotGrob?

    • baptiste
      baptiste about 8 years
      btw the "EPFL website" is just a very old version of the documentation, before ggplotGrob was removed and later re-introduced in another form, IIRC.