9/24/2020

Hello!

In this presentaion, we will use plotly to plot a simple interative graph using mtcars dataset.
I will plot horsepower vs miles per gallon and factored by cylinder.

Code

library(plotly)
## Loading required package: ggplot2
## 
## 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
library(datasets)
data("mtcars")

Plot

plot_ly(mtcars, x = mtcars$hp, y=mtcars$mpg, mode="markers", 
         type="scatter",color=as.factor(mtcars$cyl), size=mtcars$disp )