如何修复条形图的下限

时间:2013-07-08 12:39:55

标签: r bar-chart

我想在y=2 (ylim=2)

修正条形图的限制
testdata <- data.frame(group=c(1,2),
             xbar= c(3.410821 , 4.746693 ),
                 se = c(0.1593839,0.2435023))

xvals = with(testdata,barplot(xbar, names.arg=group, 
                main="",xlab="x",ylab="y",ylim=c(2,max(6))))

   with(testdata,arrows(xvals, xbar, xvals, xbar+se, length=0.3, angle=90, code=2))

1 个答案:

答案 0 :(得分:1)

设置xpd参数,如下所示:

xvals = with(testdata,barplot(xbar, names.arg=group, 
                              main="",xlab="x",ylab="y",ylim=c(2,6),xpd=FALSE))

enter image description here