10 June, 2021

Overview

This project is to create a web page presentation using R Markdown that features a plot created with Plotly and then the webpage is hosted on RPubs. The data set being used is mtcars. A graphy of scatter plot is going to show the relationship between hp (i.e. horse power ranging from 50 to 350) and mpg (i.e. fuel consumption of miles per gallon). For easy visualization, the data is further classified into 3 different types of cylinder (i.e. 4-cylinder, 6-cylinder and 8-cylinder) with a specific colour for each type of cylinder. Also, the size of each dot reflects the weight of the corresponding car (i.e. the variable wt).

Code

library(plotly)
data("mtcars")
fig <- plot_ly(data=mtcars, x=~hp, y=~mpg, color=~factor(cyl),
               size=~wt, type="scatter", mode="markers")
fig <- fig %>% layout(title=
"Scatter Plot for features of hp & mpg for the mtcars data set")
fig

Plot