
ggplot2
theme elementsAfter today’s session you will be able to:
ggplot2 graphggplot2
ggplot2 Reviewtheme parameters
theme function
element_textelement_lineelement_blanktheme function once with as many element_... functions as you need
theme and element_... functions are used togethertheme argument names as you work more with ggplot2
panel.gridpanel.backgroundaxis.line
ggplot2

theme(panel.grid = element_blank())
theme parentheses!)?
panel.background = element_blank()axis.line = element_line(color = "black")


theme
axis.title = axis label text (given to labs function)axis.text = text on axis tick marks

theme(axis.text.x = element_text(...))


theme function!
legend.positionlegend.title
element_..., legend.position wants words in quotes!
"none", "inside", "left", etc.
legend.position = "inside", you need to tell it where inside
legend.position.inside = c(<x position>, <y position>)



ggplot2::facet_grid()cowplot::plot_grid()
ggplot2 has an internal way of handling this called facets

ggplot(data = penguins, aes(x = body_mass_g, y = flipper_length_mm, color = species)) +
geom_point() +
facet_grid(. ~ island) +
labs(x = "Body Mass (g)", y = "Flipper Length (mm)") +
theme(legend.position = "inside",
legend.position.inside = c(0.87, 0.85),
legend.title = element_blank(),
panel.background = element_blank())

theme tweaks you want to make!


cowplot::plot_grid lets you put multiple different graphs together

plot_grid, make a multi-panel graph with these two graphs

