Sam Kanta
2023-11-26
This is a web (html) presentation using R Markdown that features a plot created with Plotly. The webpage contains:
Specifically, the type of plot features a scatterplot created with
Plotly using the mtcars dataset. I used this particular
dataset when completing the Regression Models Course.
The dataset from mtcars was used as the basis for plot creation. In particular, I wanted to create an interactive figure that would show datapoints for all cars in terms of their mileage, with a distinction between cars with Automatic and Manual transmission.
Here’s a chunk of the R code to deomstrate how the plot would be created. FYI, it’s also a way of demonstrating that this presentation used R Markdown and knitr.
mtcars$am[which(mtcars$am == 0)] <- 'Automatic'
mtcars$am[which(mtcars$am == 1)] <- 'Manual'
mtcars$am <- as.factor(mtcars$am)
fig <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#46eb34', '#7c807c'))
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Vehicle Weight'),
yaxis = list(title = 'Horsepower'),
zaxis = list(title = '1/4 mile time')))An interactive 3-D style plot of cars, relative to their Vehicle Weight, Horsepower, and timed speed over 0.25 of a mile.
Please feel welcome to click-drag the plot to see its interactive qualities.