<分区>
我想为包含正值和负值的数据框绘制条形图,负值应为红色。
我想避免使用 ggplot 而使用基本的 'barplot'
有什么建议吗?
这是我的代码
df <- data.frame(MM=(1:12), value=rnorm(12))
df
toplot <- df
options(repr.plot.width=6, repr.plot.height=4)
label <- seq(1:12)
a <-barplot(df$value,
names=label,
col='deepskyblue3',
xaxt = "n", yaxt = "n",
)
axis(1, cex.axis=0.55, las=1, at=a, labels=label)
axis(2, las='2', cex.axis=0.6)
abline(h = 0, col = "black")