library(ggplot2)
library(plotly)
data(mtcars)
g <- ggplot(data = mtcars, aes(x = wt, y = mpg, color = cyl)) +
geom_point() +
geom_smooth(method = "lm") +
xlab("Weight (1000 lbs)") +
ylab("Miles/(US) gallon") +
ggtitle("Miles per gallon vs Weight")
plotly.g <- ggplotly(g)
plotly.g