如何在 pdf 中将网格线放在箱线图后面
How to put gridlines behind boxplot in a pdf
我想将网格线放在箱线图后面并另存为 pdf。这该怎么做?
我可以用后面的线条生成箱线图,但是当它导出为 pdf 时,线条在图的前面
一些数据
box.data <- data.frame(one = runif(6,-0.2,1),two = runif(6,-0.2,1),three = runif(6,-0.2,1),four = runif(6,-0.2,1),five = runif(6,-0.2,1),six = runif(6,-0.2,1),seven = runif(6,-0.2,1),eight = runif(6,-0.2,1), nine = runif(6,-0.2,1))
箱线图代码
pdf("BiasBoxPlot.pdf")
boxplot(box.data, par(cex.axis=0.5),ylim=c(-0.2,1),yaxt = "n")
axis(2, yaxp=c(-2, 1, 30),cex.axis=0.5)
abline(h=seq(-0.2,1,0.05),col="grey80", lty="dotted",lwd = 0.4)
abline(v=seq(1,9),col="grey80", lty="dotted",lwd = 0.4)
boxplot(box.data,par(cex.axis=0.5),ylim=c(-0.2,1),add = TRUE)
dev.off()
看起来像这样
(请注意这是屏幕截图而不是 pdf,因为我不确定该怎么做)
这看起来很简单,但是如何让 pdf
部分起作用?
为第二个 boxplot
调用添加填充颜色:
pdf("BiasBoxPlot.pdf")
boxplot(box.data, par(cex.axis=0.5),ylim=c(-0.2,1),yaxt = "n")
axis(2, yaxp=c(-2, 1, 30),cex.axis=0.5)
abline(h=seq(-0.2,1,0.05),col="grey80", lty="dotted",lwd = 0.4)
abline(v=seq(1,9),col="grey80", lty="dotted",lwd = 0.4)
boxplot(box.data,par(cex.axis=0.5),ylim=c(-0.2,1),add = TRUE,col="white")
dev.off()
我想将网格线放在箱线图后面并另存为 pdf。这该怎么做? 我可以用后面的线条生成箱线图,但是当它导出为 pdf 时,线条在图的前面
一些数据
box.data <- data.frame(one = runif(6,-0.2,1),two = runif(6,-0.2,1),three = runif(6,-0.2,1),four = runif(6,-0.2,1),five = runif(6,-0.2,1),six = runif(6,-0.2,1),seven = runif(6,-0.2,1),eight = runif(6,-0.2,1), nine = runif(6,-0.2,1))
箱线图代码
pdf("BiasBoxPlot.pdf")
boxplot(box.data, par(cex.axis=0.5),ylim=c(-0.2,1),yaxt = "n")
axis(2, yaxp=c(-2, 1, 30),cex.axis=0.5)
abline(h=seq(-0.2,1,0.05),col="grey80", lty="dotted",lwd = 0.4)
abline(v=seq(1,9),col="grey80", lty="dotted",lwd = 0.4)
boxplot(box.data,par(cex.axis=0.5),ylim=c(-0.2,1),add = TRUE)
dev.off()
看起来像这样
(请注意这是屏幕截图而不是 pdf,因为我不确定该怎么做)
这看起来很简单,但是如何让 pdf
部分起作用?
为第二个 boxplot
调用添加填充颜色:
pdf("BiasBoxPlot.pdf")
boxplot(box.data, par(cex.axis=0.5),ylim=c(-0.2,1),yaxt = "n")
axis(2, yaxp=c(-2, 1, 30),cex.axis=0.5)
abline(h=seq(-0.2,1,0.05),col="grey80", lty="dotted",lwd = 0.4)
abline(v=seq(1,9),col="grey80", lty="dotted",lwd = 0.4)
boxplot(box.data,par(cex.axis=0.5),ylim=c(-0.2,1),add = TRUE,col="white")
dev.off()