Graphics Reference
In-Depth Information
By default, the minor grid lines appear visually halfway between the major grid lines, but this
is not the same place as the “5” tick marks on a logarithmic scale. To get them to be the
same, you can manually set the scale's
minor_breaks
. To do this, we need to set them to
lo-
ggplot(Animals, aes(x
=
body, y
=
brain, label
=
rownames(Animals)))
+
geom_text(size
=
3
)
+
annotation_logticks()
+
scale_x_log10(breaks
=
trans_breaks(
"log10"
,
function
function
(x)
10
^
x),
labels
=
trans_format(
"log10"
, math_format(
10
^
.
x)),
minor_breaks
=
log10(
5
)
+
-2
:
5
)
+
scale_y_log10(breaks
=
trans_breaks(
"log10"
,
function
function
(x)
10
^
x),
labels
=
trans_format(
"log10"
, math_format(
10
^
.
x)),
minor_breaks
=
log10(
5
)
+
-1
:
3
)
+
coord_fixed()
+
theme_bw()
Figure 8-32. Log axes with ticks at each 5, and fixed coordinate ratio