首先制作一个没有 y 轴的空图。然后绘制数据。
然后用 axis(2,...)
绘制 y 轴。为了按照问题要求格式化标签,请使用 help("formatC")
。
# test data
datereal <- Sys.Date() - 10:0
casesimm8lock7 <- seq(0,250000,length.out = 11)
# the plot
plot(datereal,casesimm8lock7,type = "n",yaxt = "n")
lines(datereal,lwd = 1,col = "red",main = "a Sensitivity to time delays: 8 month immunity",xaxt = "n",xlab = "Month",ylab = "Daily new cases",ylim = c(0,250000))
axis(2,at = seq(0,by = 50e3),labels = formatC(seq(0,format = "d",big.mark = ","))
对于包 scales
,它可以带有 label_comma
(如下所示)或 label_number
。这些函数返回一个标签函数,应用于轴标记的向量。
labeller <- scales::label_comma()
plot(datereal,labels = labeller(seq(0,by = 50e3)))
本文链接:https://www.f2er.com/31204.html