gpt4 book ai didi

r - 在 hexbin 图上添加黄土回归线

转载 作者:行者123 更新时间:2023-12-04 01:08:39 25 4
gpt4 key购买 nike

我一直在尝试寻找在 hexbin 图上添加黄土回归线的方法。到目前为止,我没有任何成功......有什么建议吗?

我的代码如下:

bin<-hexbin(Dataset$a, Dataset$b, xbins=40)

plot(bin, main="Hexagonal Binning",
xlab = "a", ylab = "b",
type="l")

enter image description here

最佳答案

我建议使用 ggplot2 来构建绘图。

由于您没有包含任何示例数据,我在下面的示例中使用了 palmerpenguins 包数据集。

library(palmerpenguins) # For the data
library(ggplot2) # ggplot2 for plotting



ggplot(penguins, aes(x = body_mass_g,
y = bill_length_mm)) +
geom_hex(bins = 40) +
geom_smooth(method = 'loess', se = F, color = 'red')

reprex package 创建于 2021-01-05 (v0.3.0)

关于r - 在 hexbin 图上添加黄土回归线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65518729/

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