# Plotly with ggplot2 does not show titles of multiple plots in R

**URL:** <https://community.plotly.com/t/plotly-with-ggplot2-does-not-show-titles-of-multiple-plots-in-r/2498>\
**Category:** Plotly R\
**Created:** [October 24, 2016, 10:04pm UTC](https://community.plotly.com/t/plotly-with-ggplot2-does-not-show-titles-of-multiple-plots-in-r/2498 "2016-10-24T22:04:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![durraniu](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@durraniu](https://community.plotly.com/u/durraniu)\
**Post date:** [October 24, 2016, 10:04pm UTC](https://community.plotly.com/t/plotly-with-ggplot2-does-not-show-titles-of-multiple-plots-in-r/2498/1 "2016-10-24T22:04:26Z")

</div>

I have asked this question on SO with no response. Here is the link: [Question on SO](http://stackoverflow.com/questions/40224778/plotly-does-not-show-titles-of-multiple-plots-in-r).

I am trying to layout 2 plots together using ggplot2 and plotly. Here’s what I tried:

```
library(ggplot2)
library(plotly)

mt_mpg <- ggplot(data = mtcars)+
  geom_boxplot(aes(x = as.factor(cyl), y = mpg))+
  ggtitle("mpg vs cyl")

mt_disp <- ggplot(data = mtcars)+
  geom_boxplot(aes(x = as.factor(cyl), y = disp))+
  ggtitle("disp vs cyl")

subplot(mt_mpg, mt_disp)    

```

Everything works great but the title of the combined plot only contains “disp vs cyl”. I want to include both titles on the top of their corresponding plots. But I don’t see any option in subplot() command to do so. Any ideas how this can be fixed? Thanks.

---

<div class="post-metadata">

**Author:** ![bcd](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@bcd](https://community.plotly.com/u/bcd)\
**Post date:** [October 24, 2016, 11:25pm UTC](https://community.plotly.com/t/plotly-with-ggplot2-does-not-show-titles-of-multiple-plots-in-r/2498/2 "2016-10-24T23:25:49Z")

</div>

Hey @durraniu

one way is to use facet\_wrap instead of ggtitle. For example:

```
df <- mtcars
df$lab1 <- 'mpg vs cyl'
df$lab2 <- 'disp vs cyl'

mt_mpg <- ggplot(df)+
  geom_boxplot(aes(x = as.factor(cyl), y = mpg))+
  facet_wrap(~lab1)

mt_disp <- ggplot(df)+
  geom_boxplot(aes(x = as.factor(cyl), y = disp))+
  facet_wrap(~lab2)

subplot(mt_mpg, mt_disp) 

```

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/36c52d9c6df3bcce92881b9bc338f82f7ad0d13c.PNG)

Hope this helps,  
Branden
