09/09/2021

Introduction

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly.

Brief Overview

The mtcars data set was used to generated the plots to examine properties of cars.

This presentation i have created 3 different plots including

  • Scatter plot
  • Boxplot
  • 3d scatter plot

Scatter plot

  1. Scatter plot
fig <- plot_ly(mtcars, x = ~wt, y = ~mpg, mode = "markers",
               color = as.factor(mtcars$cyl),
               type = "scatter",
               size = ~hp)%>%
        layout(title = "Scatter plot of mpg vs wt for each cyl by size", xaxis = list(title = "Weight"), 
               yaxis = list(title = "Miles per gallon"))

fig

Boxplot

fig2 <- plot_ly(mtcars, x = ~mpg, color = as.factor(mtcars$cyl),
                type = "box")%>%
        layout(title = "Boxplot of mpg for each cyl",
               xaxis = list(title = "mpg"),
               yaxis = list(title = "cyl"))

fig2

3D Scatter plot

fig3 <- plot_ly(mtcars, x = ~wt, y = ~mpg, z = ~gear,
                type = "scatter3d",
                mode = "markers", color = ~cyl)
fig3