3 min read•august 9, 2024
Customizing plot aesthetics and themes in ggplot2 is like giving your data a makeover. You'll learn to map data to visual elements, scale and transform aesthetics, and enhance visual appeal with palettes and fonts.
But it doesn't stop there. You'll also discover how to organize multiple plots, adjust boundaries and , and add clear labels and titles. These skills will help you create stunning, informative visualizations that make your data shine.
[aes()](https://www.fiveableKeyTerm:aes())
function defines mappings within ggplot layersscale_*()
functions modify the mapping between data and aesthetics[scale_x_continuous()](https://www.fiveableKeyTerm:scale_x_continuous())
, [scale_y_continuous()](https://www.fiveableKeyTerm:scale_y_continuous())
, [scale_color_gradient()](https://www.fiveableKeyTerm:scale_color_gradient())
[scale_color_discrete()](https://www.fiveableKeyTerm:scale_color_discrete())
, [scale_shape_manual()](https://www.fiveableKeyTerm:scale_shape_manual())
, [scale_fill_brewer()](https://www.fiveableKeyTerm:scale_fill_brewer())
[scale_x_log10()](https://www.fiveableKeyTerm:scale_x_log10())
or [scale_y_log10()](https://www.fiveableKeyTerm:scale_y_log10())
[scale_x_date()](https://www.fiveableKeyTerm:scale_x_date())
with custom date formatsscale_color_brewer()
for categorical datascale_color_gradient()
or scale_color_viridis_c()
scale_color_manual()
[theme()](https://www.fiveableKeyTerm:theme())
function, specifying font family, size, and style[geom_text()](https://www.fiveableKeyTerm:geom_text())
, [annotate()](https://www.fiveableKeyTerm:annotate())
, or [geom_rect()](https://www.fiveableKeyTerm:geom_rect())
[facet_wrap()](https://www.fiveableKeyTerm:facet_wrap())
arranges panels in a grid, wrapping to new rows as needed[facet_grid()](https://www.fiveableKeyTerm:facet_grid())
creates a matrix of panels based on two categorical variables[coord_flip()](https://www.fiveableKeyTerm:coord_flip())
swaps x and y axes, useful for horizontal bar charts[coord_polar()](https://www.fiveableKeyTerm:coord_polar())
creates circular plots, transforming cartesian to polar coordinatestheme()
function with [plot.margin](https://www.fiveableKeyTerm:plot.margin)
parameter[panel.grid.major](https://www.fiveableKeyTerm:panel.grid.major)
, [panel.grid.minor](https://www.fiveableKeyTerm:panel.grid.minor)
theme elements[theme(panel.grid = element_blank())](https://www.fiveableKeyTerm:theme(panel.grid_=_element_blank()))
[plot.background](https://www.fiveableKeyTerm:plot.background)
and [panel.background](https://www.fiveableKeyTerm:panel.background)
theme elements[strip.background](https://www.fiveableKeyTerm:strip.background)
element[ggtitle()](https://www.fiveableKeyTerm:ggtitle())
or labs(title = "My Plot Title")
[xlab](https://www.fiveableKeyTerm:xlab)()
, [ylab](https://www.fiveableKeyTerm:ylab)()
, or labs(x = "X-axis", y = "Y-axis")
labs(subtitle = "...", caption = "...")
theme()
functiontheme(legend.position = "bottom")
or removed with "none"labs(color = "New Legend Title")
scale_*_manual(labels = c("Label 1", "Label 2"))
[xlim()](https://www.fiveableKeyTerm:xlim())
, [ylim()](https://www.fiveableKeyTerm:ylim())
, or [coord_cartesian()](https://www.fiveableKeyTerm:coord_cartesian())
[scale_x_continuous(breaks = ..., labels = ...)](https://www.fiveableKeyTerm:scale_x_continuous(breaks_=_...,_labels_=_...))
[theme(axis.text.x = element_text(angle = 45, hjust = 1))](https://www.fiveableKeyTerm:theme(axis.text.x_=_element_text(angle_=_45,_hjust_=_1)))
[sec_axis()](https://www.fiveableKeyTerm:sec_axis())
function in scale_y_continuous()
scale_x_log10()
or scale_y_log10()
[theme_minimal()](https://www.fiveableKeyTerm:theme_minimal())
, [theme_bw()](https://www.fiveableKeyTerm:theme_bw())
, [theme_classic()](https://www.fiveableKeyTerm:theme_classic())
provide quick stylingelement_text()
element_line()
element_rect()
theme_set()
function