R.Y 间隔(刻度线)和网格中的箱线图
Boxplots in R. Y interval (tick marks) and grid
我有以下代码:
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 轴的百分比而不是数字。
谢谢!
不确定您的数据是什么样的,但我猜您想要这样的数据:
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))
我有以下代码:
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 轴的百分比而不是数字。
谢谢!
不确定您的数据是什么样的,但我猜您想要这样的数据:
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))