我想更改使用“binsreg”包創建的分箱散點圖的顏色。我知道如何在 ggplot 中添加線條等,但我不知道在哪里可以更改“bins_plot”中的內容。下面,您將看到一個示例。例如,如何將點的顏色從藍色變為綠色?
library(binsreg)
library(ggplot)
x <- rnorm(100,0,1)
err <- rnorm(100,0,0.5)
y <- x err
data <- data.frame(x,y)
a <- binsreg(y,x, nbins = 15)
a$bins_plot
geom_smooth(data = data, aes(x = x, y = y), method = "lm")

uj5u.com熱心網友回復:
使用函式的bycolors引數binsreg:
library(binsreg)
library(ggplot2)
set.seed(123)
x <- rnorm(100,0,1)
err <- rnorm(100,0,0.5)
y <- x err
data <- data.frame(x,y)
a <- binsreg(y, x, nbins = 15, bycolors = "green")
a$bins_plot
geom_smooth(data = data, aes(x = x, y = y), method = "lm")

由reprex 包于 2022-03-14 創建(v2.0.1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/444202.html
上一篇:ggplot線不通過形狀
