删除 error.bars 中的 x 轴

发布于 2024-11-03 00:28:24 字数 172 浏览 4 评论 0原文

我今天遇到了一个问题,我想从下面的 R 图中删除 x 轴,但它不会消失。我希望轴位于顶部。 有人能帮助我吗?

library(psych)
temp <- describe(attitude)
error.bars(stats=temp,xaxt="n")
axis(3)

I've been having a problem today, I want to remove the x-axis from the following R-plot, but it just won't disappear. I want the axis to be on top.
Is anybody able to help me?

library(psych)
temp <- describe(attitude)
error.bars(stats=temp,xaxt="n")
axis(3)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可是我不能没有你 2024-11-10 00:28:24

您可以使用 fixInNamespace() 编辑 psych 命名空间中的 error.bars() 函数。尝试:

fixInNamespace(error.bars)

这将在基本文本编辑窗口中打开该功能。找到 axis() 调用并注释掉您不需要的调用。退出编辑器,R 将更新 NAMESPACE 中的函数。

然后再次尝试使用该功能。

或者,您可以将 error.bars() 的代码打印到提示符中,将其复制到文本编辑器中,更改函数的名称,例如 my.error.bars,并像以前一样注释掉 axis() 调用。将函数保存在文件中,并将其 source() 到您的会话中,或者复制并粘贴该函数。然后根据您的需要使用。

第三种选择是弄清楚 error.bars() 如何进行基本绘图 - 查看代码。自己重新创建该图,不带轴,然后使用 add = TRUE 调用 error.bars()

You can use fixInNamespace() to edit the error.bars() function in the psych NAMESPACE. Try:

fixInNamespace(error.bars)

That will open the function in a rudimentary text editing window. Find the axis() calls and comment out the ones you don't want. Exit the editor and R will update the function in the NAMESPACE.

Then try using the function again.

Alternatively, you can print the code for error.bars() to the prompt, copy it into a text editor, change the name of the function, say to my.error.bars, and comment out the axis() calls as before. Save the function in a file and source() it into your session or copy and paste the function in. Then use to your heart's desire.

A third alternative, is to work out how error.bars() does it's base plotting - look at the code. Recreate that plot yourself, without axes, then call error.bars() with add = TRUE.

秋心╮凉 2024-11-10 00:28:24

如评论中所示,您可以编辑源代码。最简单的方法可能是使用“修复”:

eb = fix(error.bars)

应该弹出一个编辑器。将 axis(1,.etc) 调用更改为 axis(3,.etc)。然后你有一个名为 eb() 的新函数,其工作方式类似于 error.bars。

您可能还想调整其他一些东西,例如标题放置在顶部时会踩在轴上。

As in the comment, you can edit the source code. Easiest way is probably to use 'fix':

eb = fix(error.bars)

should pop up an editor. Change the axis(1,.etc.) calls to axis(3,.etc.). Then you have a new function called eb() that works like error.bars.

You might want to tweak some other things too, like the title which stomps on the axes when placed at the top.

猫九 2024-11-10 00:28:24

只是为了展示加文对 add=T 的含义:

group <- factor(rep(1:10,10))
y <- (1:10)[group] + rnorm(100)

grmean <- tapply(y,group,mean)
plot(1:10,grmean,xaxt="n",type="n")

unstacked <- unstack(data.frame(y,group),y~group)
error.bars(unstacked,add=T)
axis(3)

给出:
在此处输入图像描述

Just to show what Gavin means with add=T :

group <- factor(rep(1:10,10))
y <- (1:10)[group] + rnorm(100)

grmean <- tapply(y,group,mean)
plot(1:10,grmean,xaxt="n",type="n")

unstacked <- unstack(data.frame(y,group),y~group)
error.bars(unstacked,add=T)
axis(3)

gives :
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文