Modifying whitespace
Whitespace means all the non-visible margins and spacing in the plot.
To set a single whitespace value, use unit(x, unit)
, where x
is the amount and unit
is the unit of measure.
Borders require you to set 4 positions, so use margin(top, right, bottom, left, unit)
. To remember the margin order, think TRouBLe.
The default unit is "pt"
(points), which scales well with text. Other options include "cm", "in" (inches) and "lines" (of text).
plt_mpg_vs_wt_by_cyl
is available. The panel and legend are wrapped in blue boxes so you can see how they change.
This exercise is part of the course
Introduction to Data Visualization with ggplot2
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# View the original plot
plt_mpg_vs_wt_by_cyl
plt_mpg_vs_wt_by_cyl +
theme(
# Set the axis tick length to 2 lines
___
)