我正在barplot()
中使用grid()
。因为我想要柱子绘制在格子上方,所以我使用了panel.first
参数。然而,网格线与y轴的标记不匹配。有人能告诉我如何解决这个问题吗?我的代码如下,谢谢。
WRE <- c(1423, 41721)
bp <- barplot(WRE, xaxt = 'n', xlab = '', yaxt = 'n', las = 3, width = 0.5,
space = 1.5, main = paste("How You Compare", sep = ""), ylab = "",
names.arg = NA, col = c("red","blue"), cex.lab = 1,
panel.first = grid(nx = NA, ny = NULL))
axis(1, at=bp, labels=c("Average Claims", "Your Claims"),
tick=FALSE, las=1, line=-1, cex.axis=1)
axis(2, at=axTicks(2), sprintf("$%s", formatC(axTicks(2), digits=9, big.mark=",", width=-1)),
cex.axis=0.9, las=2)