Hover over points to inspect car names, weight, mpg, and cylinder count. The interactive plot is useful for identifying observations rather than relying only on a summary statistic.
plot_ly(cars, x = ~wt, y = ~mpg,
type = "scatter", mode = "markers",
color = ~cyl,
text = ~paste0("Model: ", model,
"<br>Weight: ", wt, " (1,000 lb)",
"<br>MPG: ", mpg,
"<br>Cylinders: ", cyl),
hoverinfo = "text",
colors = c("#FFC627", "#8C1D40", "#555555")) |>
layout(title = "Hover to inspect each car",
xaxis = list(title = "Weight (1,000 lb)"),
yaxis = list(title = "Miles per gallon"),
legend = list(title = list(text = "Cylinders")))