
Lecture 06
Cornell University
INFO 3312/5312 - Fall 2026
September 10, 2026
Source: Andrew Van Dam
x and y) to produce a two-dimension position on the plotPreserve the shape of geoms
coord_cartesian(): the default Cartesian coordinate system, where the 2D position of an element is given by the combination of the x and y positions.
coord_flip(): Cartesian coordinate system with x and y axes flipped.
Just swap the x and y aesthetics instead
coord_fixed(): Cartesian coordinate system with a fixed aspect ratio.
Use coord_cartesian(ratio = X) to set a specific aspect ratio.

Can change the shapes – a straight line may no longer be straight. The closest distance between two points may no longer be a straight line.
coord_transform(): Apply arbitrary transformations to x and y positions, after the data has been processed by the statcoord_radial(): Polar coordinatescoord_sf(): Map projectionsWhich plots will show a different smoothing curve than Plot 1?
A. Plot 2 only B. Plots 2 and 3 C. Plots 2, 3, and 4 D. None of them
00:30
base_plot +
labs(title = "Plot 1")
base_plot +
scale_x_continuous(limits = c(190, 220)) +
scale_y_continuous(limits = c(4000, 5000)) +
labs(title = "Plot 2")
base_plot +
xlim(190, 220) +
ylim(4000, 5000) +
labs(title = "Plot 3")
base_plot +
coord_cartesian(xlim = c(190, 220),
ylim = c(4000, 5000)) +
labs(title = "Plot 4")B. xlim()/ylim() are shortcuts for scale limits, so Plots 2 and 3 are identical. Plot 4 fits the smooth on all the data, then zooms.
base_plot +
labs(title = "Plot 1")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 2 rows containing non-finite outside the scale range (`stat_smooth()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
base_plot +
scale_x_continuous(limits = c(190, 220)) +
scale_y_continuous(limits = c(4000, 5000)) +
labs(title = "Plot 2")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 235 rows containing non-finite outside the scale range (`stat_smooth()`).
## Warning: Removed 235 rows containing missing values or values outside the scale range
## (`geom_point()`).
base_plot +
xlim(190, 220) +
ylim(4000, 5000) +
labs(title = "Plot 3")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 235 rows containing non-finite outside the scale range (`stat_smooth()`).
## Removed 235 rows containing missing values or values outside the scale range (`geom_point()`).
base_plot +
coord_cartesian(xlim = c(190, 220),
ylim = c(4000, 5000)) +
labs(title = "Plot 4")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 2 rows containing non-finite outside the scale range (`stat_smooth()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).scale_*_continuous(limits = ...)xlim() and ylim()coord_cartesian(xlim = ..., ylim = ...)coord_cartesian(ratio = X)Useful when having a fixed aspect ratio makes sense, e.g. scores on two tests (reading and writing) on the same scale (0 to 100 points)


Source: Wikimedia Commons
More examples: R Graph Gallery
Source: /u/andrew_elliot
Source: /u/jiuguangw
coord_radial()| Rank | Perceptual Task | Chart Examples |
|---|---|---|
| 1 | Position (common scale) | Bar chart, dot plot |
| 2 | Position (non-aligned) | Small multiples |
| 3 | Length | Stacked bar (non-baseline) |
| 4 | Angle | Pie chart |
| 5 | Circular area | Bubble chart |
| 6 | Rectangular area | Treemap |


Image credit: YouGov


For categorical variables with few levels, pie charts can work well
For categorical variables with many levels, pie charts are difficult to read




Which cognitive tasks are enabled by each chart type?


02:00
Adapted from {waffle} documentation
ae-05Instructions
ae-05 (repo name will be suffixed with your GitHub name).renv::restore() to install the required packages, open the Quarto document in the repo, and follow along and complete the exercises.15:00
ggplot(data = gapminder, mapping = aes(x = year, y = gdpPercap)) +
geom_line(mapping = aes(group = country), color = "grey70") +
geom_smooth(linewidth = 1.25, method = "loess", se = FALSE) +
scale_y_log10(labels = label_currency(scale_cut = cut_short_scale())) +
facet_wrap(facets = vars(continent)) +
labs(
title = "GDP per capita across continents",
x = "Year",
y = "GDP per capita",
color = "Legend"
)facet_*()facet_wrap()
facet_grid() for faceting
facet_null(): a single plot, the default
Freeing the y scale improves the display, but it’s still not satisfying. What’s wrong with it?


ggplot(penguins, aes(y = species, x = body_mass, fill = species)) +
geom_boxplot(show.legend = FALSE) +
facet_grid(rows = vars(island)) +
labs(title = "Same scale and spacing")
ggplot(penguins, aes(y = species, x = body_mass, fill = species)) +
geom_boxplot(show.legend = FALSE) +
facet_grid(rows = vars(island), scales = "free_y") +
labs(title = "Free y scale, same spacing")In the Gentoo panel, how many gray points appear?
00:30
D. Dropping species leaves the gray layer with nothing to facet on, so {ggplot2} draws all of it in every panel. The colored layer still has species, so it splits normally.