In ggplot2, theme() controls non-data presentation settings. It can replace defaults with choices such as a bold plot title, while the data mappings and geometric layer remain unchanged. section 2.5.3 section 8.6
Emphasize an NBA histogram title
After building a histogram of career win shares with ggplot(), aes(), geom_histogram(), and labs(), add `theme(plot.title = element_text(face = "bold"))`. The resulting chart uses a bold title while retaining its royal-blue bins and NBA-focused labels. section 2.5.3
p1 <- ggplot(draft, aes(x = WS)) +
geom_histogram(fill = "royalblue3", color = "royalblue3",
bins = 8) +
labs(title = "Career Win Shares Distribution of
NBA First-Round Selections",
subtitle = "2000-09 NBA Drafts",
x = "Career Win Shares",
y = "Frequency") +
theme(plot.title = element_text(face = "bold"))
print(p1)
View the complete ggplot2 command that combines data mapping, histogram geometry, labels, and title styling. section 2.5.3
