In-Class Exercise 9
Shih Chien University
2026-08-03
Draw the Old Faithful density surface with geom_raster():
Render it twice: once with the default continuous fill scale, and once adding scale_fill_viridis_c().
Write one sentence on why the viridis version is preferred (perceptual uniformity: equal steps in the data look like equal steps in colour, and it survives greyscale printing).
Make a bar chart of class counts in mpg, filled by drv. Replace the default discrete colours with a colourblind-safe palette, e.g. scale_fill_brewer(palette = "Set2") or scale_fill_viridis_d().
Write one sentence explaining why red–green default-style palettes are risky and roughly what share of the audience may be affected by colour-vision deficiency.
Using mpg, plot displ vs hwy and map cyl (number of cylinders) to point size. Compare the default scale_size() with scale_size_area().
Write two sentences: what does scale_size_area() guarantee about the mapping (value proportional to area, and zero maps to zero size), and why is scaling the radius instead of the area misleading?
Complete your answers in the official template from the Problem sets page (author = your student ID only; keep the UUID chunk). Knit to PDF, name it ex9-[StudentID].pdf, and upload it to the course pCloud folder before midnight of the following week.
ggplot2: Elegant Graphics for Data Analysis