Horsepower vs. MPG

This plot is interactive. You can hover over the points to see details, zoom in, and pan.

library(plotly)

# Create an interactive scatter plot
plot_ly(mtcars, x = ~hp, y = ~mpg, type = "scatter", mode = "markers",
        color = ~as.factor(cyl), size = ~wt,
        text = ~paste("Car:", rownames(mtcars))) %>%
  layout(title = "Car Performance: MPG vs Horsepower",
         xaxis = list(title = "Horsepower"),
         yaxis = list(title = "Miles Per Gallon"))