目的
在axis()
之后用barplot()
水平标记标签。
代码
par(mai=c(2, 1, 1, 1), lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is bar 1...1","This is bar 1...2",
"This is bar 1...3","This is bar 1...4"),
xpd=TRUE, las=2, lwd=2, axes=FALSE, axis.lty=1,
cex.axis=1, cex.names=1, cex.main=1, ylim=c(-5,8.5),xlim=c(-6,5))
axis(2, -3:9)
见图片
答案 0 :(得分:3)
你快到了!您可以为x轴设置las,但不为y设置(单独调用)。这里:
par(mai=c(2, 1, 1, 1), lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is bar 1...1","This is bar 1...2",
"This is bar 1...3","This is bar 1...4"),
xpd=TRUE, las=2, lwd=2, axes=FALSE, axis.lty=1,
cex.axis=1, cex.names=1, cex.main=1, ylim=c(-5, 8.5), xlim=c(-6, 5))
axis(2, -3:9, las=2)