如何在R中的散点图上生成特定数量的Y轴刻度标记

use*_*007 1 r scatter-plot ggplot2

下面是我的代码,我只想让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 %")
Run Code Online (Sandbox Code Playgroud)

rmb*_*man 5

尝试将此图层添加到您的ggplot:

scale_y_continuous(breaks=seq(min(data$Y),max(data$Y),(max(data$Y)-min(data$Y))/20))
Run Code Online (Sandbox Code Playgroud)

breaks=参数采用允许您手动指定中断的向量.为了从最低的20个等距值,最高值data$Yseq功能就派上用场了.您还可以seq()使用round()函数包装函数以清除由此产生的潜在混乱数字max()-min()/20.