Graphics Reference
In-Depth Information
Figure 8-5. Box plot on which y range has been expanded to include 0
Reversing a Continuous Axis
Problem
You want to reverse the direction of a continuous axis.
Solution
reversed by specifying the limits in reversed order, with the maximum first, then the minimum:
ggplot(PlantGrowth, aes(x
=
group, y
=
weight))
+
geom_boxplot()
+
scale_y_reverse()
# Similar effect by specifying limits in reversed order
ggplot(PlantGrowth, aes(x
=
group, y
=
weight))
+
geom_boxplot()
+
ylim(
6.5
,
3.5
)