
Day 04
Carleton College
Stat 220 - Fall 2026
ggplot2 reviewggplot2geom_point()geom_histogram()geom_boxplot()geom_violin()geom_bar()x and y axiscolorshapealphasizelabs()In 2018, Carleton’s in-state tuition was about $55,000 a year. Was that a lot? And what did Carleton graduates earn? I’d like to make an argument about how Carleton compares to other colleges, using the tuition and pay data from Day 1.

.qmd template for today at the course website
08:00

We’re not quite satisfied….
Setting = choosing a certain value for an aesthetic
Make “small multiples”, where each facet shows a subset of the data

Tip
You may have seen this before using the syntax facet_wrap(~type). Both work, but vars() is the more modern/flexible syntax, so that’s what I’ve used here
50 colors are too many to tell apart. Instead, I made a group variable that splits schools into Carleton, other Minnesota colleges, and everywhere else. (We’ll learn to make variables like this next week!)
Examples:
scale_color_manual()
scale_color_brewer()
scale_color_viridis_c()
scale_shape_manual()
Recommended reading:

Sometimes the variable we color by is numeric, like the percent of graduates with STEM degrees. Then we need a continuous color scale.
Let’s make Carleton gold2, other Minnesota colleges navyblue, and everyone else gray70

You may have to try a few things to get the colors in the right order
Theme: The non-data ink on your plots




ggplot2 themes
theme_grey()theme_bw()theme_linedraw()theme_light()theme_dark()theme_minimal()theme_classic()theme_void()theme_test()ggthemes themes
theme_clean()theme_economist()theme_excel()theme_fivethirtyeight()theme_gdocs()theme_solarized()theme_stata()theme_tufte()theme_wsj()Apply theme_light() to the scatterplot

00:30

?themetheme(line, rect, text, title, aspect.ratio, axis.title, axis.title.x,
axis.title.x.top, axis.title.x.bottom, axis.title.y, axis.title.y.left,
axis.title.y.right, axis.text, axis.text.x, axis.text.x.top,
axis.text.x.bottom, axis.text.y, axis.text.y.left, axis.text.y.right,
axis.ticks, axis.ticks.x, axis.ticks.x.top, axis.ticks.x.bottom,
axis.ticks.y, axis.ticks.y.left, axis.ticks.y.right, axis.ticks.length,
axis.line, axis.line.x, axis.line.x.top, axis.line.x.bottom, axis.line.y,
axis.line.y.left, axis.line.y.right, legend.background, legend.margin,
legend.spacing, legend.spacing.x, legend.spacing.y, legend.key,
legend.key.size, legend.key.height, legend.key.width, legend.text,
legend.text.align, legend.title, legend.title.align, legend.position,
legend.direction, legend.justification, legend.box, legend.box.just,
legend.box.margin, legend.box.background, legend.box.spacing,
panel.background, panel.border, panel.spacing, panel.spacing.x,
panel.spacing.y, panel.grid, panel.grid.major, panel.grid.minor,
panel.grid.major.x, panel.grid.major.y, panel.grid.minor.x,
panel.grid.minor.y, panel.ontop, plot.background, plot.title,
plot.subtitle, plot.caption, plot.tag, plot.tag.position, plot.margin,
strip.background, strip.background.x, strip.background.y,
strip.placement, strip.text, strip.text.x, strip.text.y,
strip.switch.pad.grid, strip.switch.pad.wrap, ..., complete = FALSE,
validate = TRUE)ggplot(college_pay) +
geom_point(
aes(x = in_state_tuition,
y = mid_career_pay,
color = group),
alpha = 0.6,
size = 2
) +
scale_color_manual(values = c("gold2", "navyblue", "gray70")) +
theme_minimal() +
theme(
legend.position = "top"
) +
labs(
x = "In-state tuition",
y = "Median mid-career pay",
color = "",
title = "Carleton: top 4% in tuition, top 13% in pay"
)
ggplot(college_pay) +
geom_point(
aes(x = in_state_tuition,
y = mid_career_pay,
color = group),
alpha = 0.6,
size = 2
) +
scale_color_manual(values = c("gold2", "navyblue", "gray70")) +
theme_minimal() +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
) +
labs(
x = "In-state tuition",
y = "Median mid-career pay",
color = "",
title = "Carleton: top 4% in tuition, top 13% in pay"
)
ggplot(college_pay) +
geom_point(
aes(x = in_state_tuition,
y = mid_career_pay,
color = group),
alpha = 0.6,
size = 2
) +
scale_color_manual(values = c("gold2", "navyblue", "gray70")) +
scale_x_continuous(labels = scales::dollar) +
scale_y_continuous(labels = scales::dollar) +
theme_minimal() +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
) +
labs(
x = "In-state tuition",
y = "Median mid-career pay",
color = "",
title = "Carleton: top 4% in tuition, top 13% in pay"
)
ggplot(college_pay) +
geom_point(
aes(x = in_state_tuition,
y = mid_career_pay,
color = group),
alpha = 0.6,
size = 2
) +
scale_color_manual(values = c("gold2", "navyblue", "gray70")) +
scale_x_continuous(labels = scales::dollar) +
scale_y_continuous(labels = scales::dollar) +
theme_minimal() +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
) +
labs(
x = "In-state tuition",
y = "Median mid-career pay",
color = "",
title = "Carleton: top 4% in tuition, top 13% in pay"
) +
annotate("point",
x = 54759,
y = 109900,
shape = 1,
size = 7,
stroke = 1.2,
col = "gold4") +
annotate("text",
x = 52500,
y = 109900,
label = "Carleton",
hjust = 1,
fontface = "bold",
col = "gold4")
Tip
I had to look these values up in the data, and try a few different combinations to get it to look OK
ggplot(college_pay) +
geom_point(
aes(x = in_state_tuition,
y = mid_career_pay,
color = group),
alpha = 0.6,
size = 2
) +
scale_color_manual(values = c("gold2", "navyblue", "gray70")) +
scale_x_continuous(labels = scales::dollar) +
scale_y_continuous(labels = scales::dollar) +
theme_minimal(base_size = 20) +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
) +
labs(
x = "In-state tuition",
y = "Median mid-career pay",
color = "",
title = "Carleton: top 4% in tuition, top 13% in pay"
) +
annotate("point",
x = 54759,
y = 109900,
shape = 1,
size = 7,
stroke = 1.2,
col = "gold4") +
annotate("text",
x = 52500,
y = 109900,
label = "Carleton",
hjust = 1,
fontface = "bold",
size = 6,
col = "gold4")

What a huge effect! 
But it isn’t the whole story


00:30

Wilke has good suggestions in chapters 5-16
Always stop and think about how easy it is to see the story
Try a few different options
![]()



One way to do this is by highlighting the important parts


Is this train schedule easy to read?

Does removing gridlines make it somewhat easier?

“We focus on four conventions which imbue visualisations with a sense of objectivity, transparency and facticity. These include: a) two-dimensional viewpoints; b) clean layouts; c) geometric shapes and lines; d) the inclusion of data sources.”


Both are true. Which would go in an admissions brochure? Which would go in a critique of college costs?
Why does the graph on the right have such a strong negative trend?




Now that we have the toolkit to make customizations to our plots, and some “rules” for good graphs, let’s break them!
Choose a graph (the one from class today, one from last class, one from homework, etc.)
Make it ugly
color scaletheme optionsExplain why it’s ugly (what “rules” are you breaking? what makes it an ineffective graph?)
Post to the “Day04” post on our Ed board when you’re done (you don’t have to post your explanation)
Look through the posts and ♥ any that are especially good (bad)!