Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的条形图标签:在打印区域下方添加水平线_R_Bar Chart - Fatal编程技术网

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研究中,如果我放大或缩小生成的图形,它会出错。绘图下方的水平线将消失。