data(mtcars)
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$am <- factor(mtcars$am, labels = c("Manual", "Automatic"))
g <- ggplot(mtcars, aes(mpg, fill = as.factor(cyl)))+
geom_histogram(binwidth = 1) +
ggtitle("Histogram of miles per gallon from MTCARS") +
facet_wrap(~am)
ggplotly(g)