Lecture 09
Cornell University
INFO 3312/5312 - Fall 2026
September 24, 2026
|
|
|
|
|
|
|
|
Source: Lisa Charlotte Muth
Source: Lisa Charlotte Muth
| Scale function | Aesthetic | Data type | Palette type |
|---|---|---|---|
scale_color_hue()
|
color
|
discrete | qualitative |
scale_fill_hue()
|
fill
|
discrete | qualitative |
scale_color_gradient()
|
color
|
continuous | sequential |
scale_color_gradient2()
|
color
|
continuous | diverging |
scale_fill_viridis_c()
|
color
|
continuous | sequential |
scale_fill_viridis_d()
|
fill
|
discrete | sequential |
scale_color_brewer()
|
color
|
discrete | qualitative, diverging, sequential |
scale_fill_brewer()
|
fill
|
discrete | qualitative, diverging, sequential |
scale_color_distiller()
|
color
|
continuous | qualitative, diverging, sequential |
โฆ and there are many many more
Scale name: scale_<aesthetic>_<datatype>_<colorscale>()
<aesthetic>: name of the aesthetic (fill, color)<datatype>: type of variable plotted (discrete, continuous, binned)<colorscale>: type of the color scale (qualitative, sequential, diverging, divergingx)| Scale function | Aesthetic | Data type | Palette type |
|---|---|---|---|
scale_color_discrete_qualitative() |
color |
discrete | qualitative |
scale_fill_continuous_sequential() |
fill |
continuous | sequential |
scale_fill_binned_diverging() |
fill |
binned | diverging |
| Color name | Hex code | R, G, B (0-255) |
|---|---|---|
| Black | #000000 | 0, 0, 0 |
| Orange | #E69F00 | 230, 159, 0 |
| Sky Blue | #56B4E9 | 86, 180, 233 |
| Bluish Green | #009E73 | 0, 158, 115 |
| Yellow | #F0E442 | 240, 228, 66 |
| Blue | #0072B2 | 0, 114, 178 |
| Vermilion | #D55E00 | 213, 94, 0 |
| Reddish Purple | #CC79A7 | 204, 121, 167 |




โThis is what customers pay us for โ to sweat all these details so itโs easy and pleasant for them to use our computers.โ




How can the following figure be improved with custom breaks in axes, if at all?
Image credit: STA 313
How can plots be annotated to enhance their clarity and interpretability?
04:00
Image credit: Flowing Data
04:00
Image credit: Charted: Median House Prices vs. Income in the U.S.
geom_text(), geom_label(), geom_text_repel(), etc.
ggplot(
gapminder_europe,
aes(x = gdpPercap, y = lifeExp)
) +
geom_point(aes(color = should_be_labeled)) +
geom_label_repel(
data = filter(
gapminder_europe,
should_be_labeled == TRUE
),
aes(
label = country,
fill = should_be_labeled
),
color = "white"
) +
scale_color_manual(values = c(
"grey50",
"red"
)) +
scale_fill_manual(values = c("red")) +
guides(color = "none", fill = "none")
# Color just Oceania
gapminder_highlighted <- gapminder |>
mutate(
is_oceania = continent == "Oceania"
)
ggplot(
gapminder_highlighted,
aes(
x = year, y = lifeExp,
group = country,
color = is_oceania,
linewidth = is_oceania
)
) +
geom_line() +
scale_color_manual(values = c(
"grey70",
"red"
)) +
scale_linewidth_manual(values = c(0.1, 0.5)) +
guides(color = "none", linewidth = "none") +
theme_minimal()
geom_text(), geom_label(), geom_text_repel(), etc.
annotate()
ggplot(
gapminder_europe,
aes(x = gdpPercap, y = lifeExp)
) +
geom_point() +
annotate(
geom = "rect",
xmin = 30000, xmax = 50000,
ymin = 78, ymax = 82,
fill = "red", alpha = 0.2
) +
annotate(
geom = "label",
x = 40000, y = 76.5,
label = "Rich and long-living"
) +
annotate(
geom = "segment",
x = 40000, xend = 40000,
y = 76.8, yend = 77.8,
arrow = arrow(
length = unit(0.1, "in")
)
)
2026 Winter Olympics figure skating โธ๏ธ drama!
The gold medal win in Ice Dance ๐ง๐ by the French ๐ซ๐ท๐ฅ team of Laurence Fournier Beaudry & Guillaume Cizeron over the American ๐บ๐ธ๐ฅ team of Madison Chock & Evan Bates has become a controversy
The free dance was scored by 9 judges
The French judge gave Beaudry & Cizeron ๐ซ๐ท a 137.45 but only gave Chock & Bates ๐บ๐ธ a 129.74
All other judges were relatively close in their scores of the two teams ๐ค
Figure skating uses a โtrimmed meanโ to determine final scores, meaning the top and bottom judgesโ scores are discarded from the averages. Still, an outlier score can have an impact, since it affects which other scores are counted. I have yet to see a thorough mathematical analysis of whether or not the French judge lowballing Chock & Bates actually prevented them from winning gold. Can anyone help out here?
Also, judge No. 4 was just in a bad mood overall ๐
#dataviz #figureskating #olympics #winterolympics #iceskating #skating #usfigureskating #icedance
Source: @datakabas
Credit: Data Visualization with R
ae-08Brainstorm methods to improve the readability and interpretability of the chart through annotations
What is a โgoodโ rank? What is a โbadโ rank?
Note
What are the countries that have significantly improved or worsened their rank?
What other aspects do you feel should be emphasized?