在 R 中使用plotCI 时更改参数。(向左或向右移动点)
我知道您可以通过在代码中添加“at=1:6-0.2”或“at=1:6+0.2”来在图表上向左或向右移动箱线图,但当我使用plotCI时情况并非如此。有谁知道如何执行这个简单的参数调整?我知道这一定很简单,但是这里关于plotCI 的问题很少。它位于包 {gplots} 中。这让我发疯!感谢您的任何帮助。 -亚历克斯
I know that you can shift boxplots left or right on a graph by adding "at=1:6-0.2" or "at=1:6+0.2" to the code, but the same is not the case when I am using plotCI. Does anyone know how to perform this simple parameter adjustment? I know it has to be easy but there are very few questions about plotCI on here. It is in the package {gplots}. This is driving me crazy! Thanks for any help.
-Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你想移动一切(点和误差线),那么你需要做的就是向plotCI的x参数添加少量:
但这看起来很奇怪,所以也许你的意思是你想要将点绘制在正确的位置,但将误差线稍微向右移动?这对我来说仍然很奇怪,但是可以通过获取plotCI的代码,将其放入包装函数中并向包装函数添加一个小的偏移参数(该参数传递到plotCI代码的相关部分)来相当容易地完成。
经过检查,plotCI 的代码有点长,所以我不会在这里重现整个内容。在控制台中输入plotCI,然后将结果复制并粘贴到文本文件中,然后将该函数命名为新名称,例如plotCI_offset。我相信,如果您随后在最后的 if/else 语句中更改 myarrow 函数调用的 x 坐标参数,您将获得成功。
新函数 def 看起来像这样:
我已经引用了下面函数的更改位:
然后就在下面更改此代码,如下所示:
这仅处理误差线垂直的情况。但水平情况下的改变是相似的。
If you want to shift everything (points and error bars) then all you need to do is add a small amount to the x parameter of plotCI:
But that seems weird, so maybe you meant that you want to plot the points in the correct position, but shift the error bars slightly to the right? That still seems odd to me, but it can be done fairly easily by grabbing the code for plotCI, putting it in a wrapper function and adding a small offset parameter to your wrapper function that is passed to the relevant portion of the plotCI code.
Upon checking, that code for plotCI is a bit long, so I won't reproduce the whole thing here. Type plotCI at the console, and copy and paste the result in a text file, and call the function something new, like plotCI_offset. I believe if you then change the x coordinate parameters of the myarrow function call in the final if/else statement, you'll be golden.
The new function def would look like this:
And I've quoted the altered bits of the function below:
Then just below there alter this code as follows:
This only takes care of the case where the error bars are vertical. But the alterations for the horizontal case are similar.
试试这个:
现在做同样的事情,但像这样:
......
Try this:
Now do the same but like this:
......
我对此有一个技巧:您不移动数据点,而是移动轴上的标签!
例如,您想要将数据点在 x 轴上向右移动 1,您可以隐藏 x 轴并使用新标签重新绘制它:
I have a hack for that: you do not move your data points, rather, you move the labels on the axes!
e.g. you want to shift your data points to the right by 1 on x-axis, you hide the x-axis and redraw it with new labels: