(参考自《R数据可视化手册》8.8节)
目的:主动设置坐标轴刻度,就是想在坐标轴的哪里标注那一处的度量值。
作者说:Usually ggplot does a good job of deciding where to put the tick marks, but if you want to change them,set breaks in the scale.
通常ggplot设置的坐标轴刻度线都还不错啦。七七八八啦。基本上还符合事实把。。。
1、不手动设置坐标轴刻度标签的箱线图(图1):
library(ggplot2)
ggplot(PlantGrowth, aes(x = group, y = weight)) +
geom_boxplot()
2、设置坐标轴刻度线(breaks)在4, 4.25, 4.5等处显示(图2):
ggplot(PlantGrowth, aes(x = group, y = weight)) +
geom_boxplot() +
scale_y_continuous(breaks = c(4, 4.25, 4.5, 5, 6, 8))