In this challange, I explored car efficiency data using the
mpg dataset. I tried to built an interactive plot showing
the relationship between engine size, fuel efficiency, and vehicle
class. In Task 2 I used geom_point to make a plot of Engine Size vs
Highway MPG classed by Vehicle Type. The use of plotly
enabled me to improve the tooltip experience and make the visualization
more engaging and informative. For Task 3 I experimented with a few more
interactive plots and made the dashboard.
library(tidyverse)
library(plotly)
data(mpg)
sample_diamonds <- diamonds %>% sample_n(1000)
p <- ggplot(mpg, aes(x = displ, y = hwy,
color = class,
text = paste("Model:", model,
"<br>Manufacturer:", manufacturer,
"<br>Displ (L):", displ,
"<br>Highway MPG:", hwy,
"<br>Class:", class))) +
geom_point(size = 3, alpha = 0.7) +
labs(title = "Engine Size vs Highway MPG",
x = "Displacement (Liters)",
y = "Highway Miles per Gallon",
color = "Vehicle Class") + theme_bw()
ggplotly(p, tooltip = "text")