如何以百万为单位设置 Boxplot Y 轴限制

How to set Boxplot Y axis limits in millions

当我使用 R 箱线图函数绘制箱线图时,此函数会自动打印 y 轴。

boxplot(x=DF$Baseline.Investment, xlab="Baseline.Investment",col=c('green'))

我希望将 y 轴限制更改为百万。有人可以帮忙解决这个问题吗? 提前致谢。

enter image description here

简单的方法

set.seed(42)
x <- rlnorm(100, 12, 2)
boxplot(x/1e6, ylab="Amount in Millions")

如果您想更好地控制轴标签,请创建您自己的轴:

boxplot(x, yaxt="n", ylab="Amount in Millions")
axis(2, c(0, 5e6, 1e7, 1.5e7), c("0", "5", "10", "15"), las=1)