R中的条形图标签:在打印区域下方添加水平线
我的代码:R中的条形图标签:在打印区域下方添加水平线,r,bar-chart,R,Bar Chart,我的代码: x <- c(10, 50, 20, 40) barplot(x, names.arg=LETTERS[1:4]) x您可以使用mtext mtext("E", side = 1, line = 3, adj = 0.375) mtext("F", side = 1, line = 3, adj = 0.875) 然后用线画线,但表示xpd=T lines(c(0,3.5),c(-10,-10),xpd=TRUE) lines(c(3.8,4.8),c(-10,-10),x
x <- c(10, 50, 20, 40)
barplot(x, names.arg=LETTERS[1:4])
x您可以使用mtext
mtext("E", side = 1, line = 3, adj = 0.375)
mtext("F", side = 1, line = 3, adj = 0.875)
然后用线
画线,但表示xpd=T
lines(c(0,3.5),c(-10,-10),xpd=TRUE)
lines(c(3.8,4.8),c(-10,-10),xpd=TRUE)
但是,您需要手动调整它。
多亏了帕斯卡。我得到了另一个答案
x <- c(10, 50, 20, 40)
barplot(x, names.arg=LETTERS[1:4])
mtext("E", side = 1, line = 3, adj = 0.375)
mtext("F", side = 1, line = 3, adj = 0.875)
axis(1, at=c(0.5,1,2,3,3.3), line=2.5, tick=T, labels=rep("",5), lwd=2, lwd.ticks=0)
axis(1, at=4+c(0.1,0.2,0.3,0.4,0.5),line=2.5,tick=T,labels=rep("",5), lwd=2, lwd.ticks=0)
x能帮上忙吗?@Pascal这很有用。在R或R研究中,如果我放大或缩小生成的图形,它会出错。绘图下方的水平线将消失。