barplot:如何获取 y 轴和框外的 y 轴标签,用 box() 创建?
barplot: How to get the labels of y-axis outside the y-axis and the box, created with box()?
条形图在 PDF 文件中看起来很奇怪。代码:
pdf("fileName2.pdf", width=100, height=75)
par(resetPar())
par(mar=c(30, 150, 7, 7), lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is \nbar 2...1","This is bar 2...2",
"This is bar 2...3","This is bar 2...4"), , xpd=TRUE, las=1, lwd=3,
horiz=TRUE, axes=TRUE, axis.lty=1, space=1, cex.axis=22, cex.names=22)
box(which="plot", lty="solid")#lty = '1373'
dev.off()
问题:
如何在框外获取 y 轴(这里是 x 轴,因为 horiz=TRUE)的标签(1 到 15)?
您的 pdf 非常大,因为宽度和高度是以英寸为单位指定的。您的 cex 参数也很大。您的参数较小的代码绘制一切正常:
pdf(fileName2.pdf",width = 12) par(mar=c(4,10,4,1),cex=2, lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is \nbar 2...1","This is bar 2...2",
"This is bar 2...3","This is bar 2...4"), las=1,horiz=TRUE, axes=TRUE)
box(which="plot", lty="solid")
dev.off()
条形图在 PDF 文件中看起来很奇怪。代码:
pdf("fileName2.pdf", width=100, height=75)
par(resetPar())
par(mar=c(30, 150, 7, 7), lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is \nbar 2...1","This is bar 2...2",
"This is bar 2...3","This is bar 2...4"), , xpd=TRUE, las=1, lwd=3,
horiz=TRUE, axes=TRUE, axis.lty=1, space=1, cex.axis=22, cex.names=22)
box(which="plot", lty="solid")#lty = '1373'
dev.off()
问题: 如何在框外获取 y 轴(这里是 x 轴,因为 horiz=TRUE)的标签(1 到 15)?
您的 pdf 非常大,因为宽度和高度是以英寸为单位指定的。您的 cex 参数也很大。您的参数较小的代码绘制一切正常:
pdf(fileName2.pdf",width = 12) par(mar=c(4,10,4,1),cex=2, lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is \nbar 2...1","This is bar 2...2",
"This is bar 2...3","This is bar 2...4"), las=1,horiz=TRUE, axes=TRUE)
box(which="plot", lty="solid")
dev.off()