ggplot() IntroJanuary 2, 2026
ggplot(){patchwork}Single Numerical Variable
Single Categorical Variable
Two Numerical Variables
Two Categorical Variables
One Numerical and One Categorical Variable
Visualizing the Austin Zillow Data subsectionggplot()Note we can pipe (%>%) a data frame into a plot
Once we use ggplot() we use + to add layers instead of piping
geom_*() layers require aesthetics to map variables to plot features
Can add multiple geoms to a single plot
Every plot should include labels
Single Numerical Variable
geom_boxplot(), geom_histogram(), or geom_density()
x or y aesthetic (but not both!)geom_density(aes(x = hwy))Single Categorical Variable
geom_bar()
x or y aesthetic (but not both!)geom_bar(aes(x = class))geom_col()
x and y aestheticgeom_col(aes(x = class, y = n))Two Numerical Variables
geom_point() or geom_hexbin()
x and y aestheticgeom_point(aes(x = cty, y = hwy))Two Categorical Variables
geom_bar()
x and fill aestheticsgeom_bar(aes(x = class, fill = drv))One Numerical and One Categorical Variable
geom_boxplot()
x and y aestheticsgeom_boxplot(aes(x = hwy, y = class))geom_density() or geom_histogram()
x aestheticfacet_wrap(~ VAR_NAME)Other available aesthetics include color, size, shape, and alpha (transparency)
\(\bigstar\) Build plot(s) to help answer give us insight into the distribution of the lot size variable. If you’re successful (or if you just want to try something else), move on to plots that show the distribution of city or price range, or even to try building a plot to examine a potential association between number of bedrooms and price range. Take five minutes and then we’ll debrief together.
\(\bigstar\) Use your knowledge of data visualization and ggplot to build basic plots to answer at least two of the questions you wrote out earlier. If you write broken code, troubleshoot with a neighbor, pull me over, or even post to Slack for help. See what you can do in a few minutes and then debrief together.
# r-coding-questions channel in Slack!
\(\bigstar\) Use your knowledge of data visualization and ggplot to build basic plots to answer at least two of the questions you wrote out earlier. If you write broken code, troubleshoot with a neighbor, pull me over, or even post to Slack for help. We’ll see what we can do in a few minutes and then debrief together.
Made a plot you are proud of? Post it and the code to the # r-coding-questions channel in Slack!
The labs() layer permits global plot labels and labels for any mapped aesthetic
titlesubtitlecaptionalt (for alt-text)xycolorfill
\(\bigstar\) Now that you know about labeling options in the labs() layer, update your plots with meaningful labels
{patchwork}{patchwork} package provides very easy and intuitive framework for doing this.Create each of your plots, but store them into variables p1, p2, …
Use + to organize plots side-by-side, and / to organize plots over/under one another.
(p1 + p2) / p3 will arrange plots p1 and p2 side-by-side, with plot p3 underneath them.
\(\bigstar\) Use {patchwork} to experiment with different arrangements of your plots
Ask at several more questions that can be answered using data visualization
Construct relevant visuals (including meaningful labels) to answer your questions
{patchwork} if you like{patchwork} is used versus when it is notProvide interpretations of the plots you are seeing
Navigate to our MAT241 Exit Ticket Form, answer the questions, and complete the task below.
Note. Today’s discussion is listed as 4. Data Visualization

Task: The content from the data visualization interactive notebook and this slide deck is difficult and coding heavy. You are not expected to be an expert. Do your best to describe what you might do to create a plot exploring whether an association exists between home type and the year the home was built. Discuss how the variables influence the appropriate plot type. You may also provide code or descriptions of layers using ggplot() terminology.
A Transition Into Probability