M. Chellakumar
27 February 2019
Using the mtcars dataset we attempt to understand the relationship of various factors to gas mileage (mpg) through PLOTLY.
We plot weight (wt) vs. mileage (mpg) spatially along the x/y axes. We visualize the number of cylinders (cyl) as colors and the amount of horsepower (hp) as the size of an individual point in the plot.
suppressPackageStartupMessages(library(plotly))
plot_ly(data = mtcars, x = ~wt, y = ~mpg,
color = ~as.factor(cyl), size = ~hp,
text = ~paste("Weight: ", wt, '<br>MPG:', mpg),
type = "scatter", mode = "markers") %>%
layout(title = "Car Data")