Log-transforming scales
Using scale_y_log10()
and scale_x_log10()
is equivalent to transforming our actual dataset before getting to ggplot2
.
Using coord_trans()
, setting x = "log10"
and/or y = "log10"
arguments, transforms the data after statistics have been calculated. The plot will look the same as with using scale_*_log10()
, but the scales will be different, meaning that we'll see the original values on our log10 transformed axes. This can be useful since log scales can be somewhat unintuitive.
Let's see this in action with positively skewed data - the brain and body weight of 51 mammals from the msleep
dataset.
Diese Übung ist Teil des Kurses
Intermediate Data Visualization with ggplot2
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Produce a scatter plot of brainwt vs. bodywt
ggplot(___, aes(___, ___)) +
___ +
ggtitle("Raw Values")