gpt4 book ai didi

R绘图: Making two plots closer together on the graph

转载 作者:行者123 更新时间:2023-12-02 00:24:49 26 4
gpt4 key购买 nike

我有一个用代码制作的图表:

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)

Graph

我希望第 1 组和第 2 组的图靠得更近。更像是:

Better Graph

有没有人建议如何让他们更亲密?

最佳答案

作为您的 graph() 调用的附加参数,您可以添加:xlim = c(x1,x2),其中 x1x2 是可见 x 轴的限制。

在您的情况下,由于您使用的是 x 坐标 12,因此您可以使用 xlim=c(0.5,2.5)

enter image description here

关于R绘图: Making two plots closer together on the graph,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9239043/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com