R绘图:使两个绘图在图形上更接近
我用代码制作了一个图表:R绘图:使两个绘图在图形上更接近,r,plot,R,Plot,我用代码制作了一个图表: yvalue = c(100, -100, 50, 0) xvalue = c(1, 1, 2, 2) gmin = c(-100, 0) gmax = c(100, 50) xarrow = c(1, 2, 3, 4) gplot = plot(xvalue, yvalue, xaxt="n", main="Just a graph", xlab="Groups", ylab="y-value") xvaluenames = c("Group 1", "Group 2
yvalue = c(100, -100, 50, 0)
xvalue = c(1, 1, 2, 2)
gmin = c(-100, 0)
gmax = c(100, 50)
xarrow = c(1, 2, 3, 4)
gplot = plot(xvalue, yvalue, xaxt="n", main="Just a graph", xlab="Groups", ylab="y-value")
xvaluenames = c("Group 1", "Group 2", 1, 2)
axis(1, at = 1:length(xvalue), labels = xvaluenames)
arrows(x0=xarrow, y0=gmin, x1=xarrow, y1=gmax, length=0)
abline(h=0)
我希望第1组和第2组的图更接近。更像:
有人对如何使它们更接近有建议吗?作为
graph()
调用的附加参数,您可以添加:xlim=c(x1,x2)
,其中x1
和x2
是可见x轴的限制
在您的情况下,由于您使用的是x-coords1
和2
,因此可以使用xlim=c(0.5,2.5)
更改x值并在plot()中设置xlim参数。另外,由于没有箭头,只需使用segments()@tim riffe,我在plot()中添加了type=“n”,因为我只需要这些条。