我有以下代码:
boxplot(c(Scatt_nocoop, Scatt_coop),
xlab="Scattered", col=c("red","red"),
names=c("Non-cooperative"," Cooperative "),
ylim = c(0,2.5))
我试图每0.1在Y轴上添加刻度线,然后添加一个网格。
另外,我想以百分比而不是数字来获得Y轴。
谢谢!
答案 0 :(得分:1)
不确定你的数据是什么样的,但我想你想要这样的东西:
x1 <- rnorm(100) + 2
x2 <- rnorm(100) + 2
df <- data.frame(x = c(x1, x2), g = rep(1:2,each=100))
boxplot(df$x~df$g,
xlab="Scattered", col=c("red","red"),
names=c("Non-cooperative"," Cooperative "),
ylim = c(0,5),
yaxt = "n")
添加刻度线和(手动)网格线
axis(2, at = seq(0,5,0.1))
lapply(seq(0,5,0.1), function(x) abline(a = x,b = 0))