下面是我的代码,我只想让Y轴刻度以5%为增量,刻度太多,因为它们对应于每个绘图。
library(ggplot2)
ggplot(data = data, aes(x = X, y = Y, label = Label)) +
geom_point() +
scale_colour_manual(values = c("steelblue4", "chartreuse4", "gold", "firebrick2")) +
geom_text(aes(color = Goal), position = "jitter", hjust=0.5, vjust=1.1, size = 2.3) +
labs(title = "Google", x = "Correlation Coefficient", y = "Top-Box %")
答案 0 :(得分:5)
尝试将此图层添加到您的ggplot中:
scale_y_continuous(breaks=seq(min(data$Y),max(data$Y),(max(data$Y)-min(data$Y))/20))
breaks=
参数采用一个向量,允许您手动指定中断。要从data$Y
中的最低值到最高值获得20个等间距值,seq
函数就派上用场了。您还可以使用seq()
函数包装round()
函数,以清除max()-min()/20
产生的潜在混乱数字。