Introduction

This presentation demonstrates how to create an interactive data visualization using Plotly in R. The goal is to showcase a simple dataset using an interactive plot hosted as a web page.


Dataset

We will use the built-in mtcars dataset, which contains fuel consumption and design specifications for various automobiles.


Interactive Plotly Visualization

library(plotly)

data(mtcars)

plot_ly(
  data = mtcars,
  x = ~wt,
  y = ~mpg,
  type = "scatter",
  mode = "markers",
  color = ~cyl,
  marker = list(size = 12)
) %>%
  layout(
    title = "Fuel Efficiency vs Car Weight",
    xaxis = list(title = "Weight (1000 lbs)"),
    yaxis = list(title = "Miles per Gallon")
  )