6

I am trying to make a graph with three panels. I am trying to use the functions multi plot (of ggplot2) and grid.arrange of (of gridExtra). None of them work! How could I fix this problem???

multiplot(f1.1,f1.2,f1.3)
Error: could not find function "multiplot"

grid.arrange(f1.1,f1.2,f1.3)
Error: No layers in plot
LyzandeR
  • 37,047
  • 12
  • 77
  • 87
user5385325
  • 69
  • 1
  • 1
  • 4
  • 1
    I don't think that **ggplot2** has any function called `multiplot`. – joran Sep 28 '15 at 15:54
  • 1
    Welcome to SO. Please carefully read [this](http://stackoverflow.com/help/mcve) and [this](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) and then rework your question to conform to these guidelines. – jlhoward Sep 28 '15 at 16:00
  • 1
    I suspect the poster is using code from [here](http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/). Which means one would have to actually load the function on that page. – Axeman Sep 28 '15 at 16:10
  • 1
    How are you generating your plots `f1.1` etc. ? – user20650 Sep 28 '15 at 16:41
  • 1
    This is because you have no geoms just a `ggplot` object. I can replicate the error with: `f1.1 <- f1.2 <- ggplot2::ggplot(); grid.arrange(f1.1, f1.2)` – Tyler Rinker Sep 28 '15 at 18:31

3 Answers3

5

Might I suggest installing the gridExtra package:

library(gridExtra)
arrangeGrob(f1.1, f1.2, f1.3)
Richard Ball
  • 540
  • 5
  • 14
4

Was working on also building graph based on code provided per below blog and was having same issue while using grid.arrange()

Blog : https://www.analyticsvidhya.com/blog/2017/09/comparative-stock-analysis/

grid.arrange(High,Low,ncol = 2, nrow = 1)

Installed gridExtra() package and re-executed code to resolve issue.

Martin
  • 2,411
  • 11
  • 28
  • 30
3

first you have to install the package install.package('gridExtra')

then use the library(gridExtra)

Dulakshi Soysa
  • 342
  • 3
  • 7
  • How does this answer improve on the answer provided by CuriousCoder? Perhaps a comment that you may need to install the package if you do not already have prior to calling `library(gridExtra)` – Peter May 17 '20 at 14:25