library(ggplot2)
ggplot(mpg, aes(x = displ, y = hwy, color = class)) +
geom_point()Untitled
Part 1
The points overlap, so some vehicles are hard to see. There are many colors, which makes it difficult to match points to the vehicle classes in the legend. It is also hard to compare classes because all of them appear in the same plotting area.
Part 2
ggplot(mpg, aes(x = displ, y = hwy, color = class)) +
geom_point() +
facet_wrap(~class)The separate panels make it easier to focus on one vehicle class at a time. Within the panels, I can more easily see that vehicles with larger engines generally tend to have lower highway MPG. The panels also make it easier to notice that the classes have different ranges of engine size and MPG.
Part 3
ggplot(mpg, aes(x = displ, y = hwy, color = class)) +
geom_point() +
facet_grid(class ~ drv)facet_wrap() makes separate panels for one category, vehicle class. facet_grid() organizes panels using two categories: vehicle class in the rows and drive type in the columns. The grid lets me compare vehicle classes and drive types together. Some panels are empty because the dataset does not have every combination.
Part 4
The original plot is difficult to interpret because many points and colors overlap in one area, and it is hard to tell which class a point belongs to.
facet_wrap()gives each vehicle class its own panel, making the points and patterns easier to see.facet_grid()also organizes the panels by drive type, so I can compare classes across different drive types.I would recommend
facet_wrap()for showing the relationship between engine displacement and highway MPG by vehicle class. It is easier to read than the original plot, and it has fewer panels than the grid.Too many facets can make each panel very small and harder to read. It can also take longer to compare patterns across all the panels.