在R中如何控制线和点图中点的间距

发布于 2024-10-18 09:13:14 字数 125 浏览 4 评论 0原文

所以我在 R 中有一个 plot() ,其中 type = "o" 这样我就可以同时拥有线和点。但我发现情节中比较恒定的部分有太多的点。那么,有没有办法让我增加该图中每个点之间的间距。

So I have a plot() in R with type = "o" so that I can have both line and points. But I find that there are far too many points in the more constant parts of the plot. So, is there a way for me to increase the spacing between each individual points in this plot.

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

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

发布评论

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

评论(4

后eg是否自 2024-10-25 09:13:14

我将使用 type='l' 绘制线条,然后返回并使用点函数仅添加您想要的点。

I would plot the lines using type='l', then go back and use the points function to add just the points that you want.

宫墨修音 2024-10-25 09:13:14

我建议您查看用于在 R 中绘制图形的 ggplot2 包。有多种选项可用于处理过多的点,我最喜欢的是包含 alpha 值,以便读者可以看到 1 个点和 10 个重叠点之间的差异。

library(ggplot2)
d <- ggplot(diamonds, aes(carat, price)) + geom_point(alpha = 1/10)
print(d)

I would recomend you look at the ggplot2 package for drawing graphs in R. This has several options for dealing with an over abundance of points, my favorite is including an alpha value so the reader can see the difference between one point and ten overlaid.

library(ggplot2)
d <- ggplot(diamonds, aes(carat, price)) + geom_point(alpha = 1/10)
print(d)
国产ˉ祖宗 2024-10-25 09:13:14

请参阅 help(par) 以及线型的讨论。

编辑:或者尝试以下操作:

plot(1:10, type='n', xlim=c(1,10), ylim=c(0,7))
for (i in 1:6) lines(1:10, rep(i, 10), lty=i)

使用六种预定义的线类型绘制六条线。

Please see help(par) and the discussion of line types.

Edit: Or just try the following:

plot(1:10, type='n', xlim=c(1,10), ylim=c(0,7))
for (i in 1:6) lines(1:10, rep(i, 10), lty=i)

which plots six lines with the six pre-defined line types.

沒落の蓅哖 2024-10-25 09:13:14

与 PaulHurleyuk 提出的建议类似,但使用 Bioconductor geneplotter 包:

source("http://bioconductor.org/biocLite.R")
biocLite("geneplotter")    
library(ggplot2)
data(diamonds)
library(geneplotter)
smoothScatter(diamonds$carat,diamonds$price)

在此处输入图像描述

Similar to the advice proposed by PaulHurleyuk but using the Bioconductor geneplotter package:

source("http://bioconductor.org/biocLite.R")
biocLite("geneplotter")    
library(ggplot2)
data(diamonds)
library(geneplotter)
smoothScatter(diamonds$carat,diamonds$price)

enter image description here

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