I want to change the color of a binned scatter plot that is created with the "binsreg" package. I know how to add lines etc. within a ggplot, but I don't know where I can change things within the "bins_plot". Below, you see an example. How do I change the color of the points from blue to green, for instance?
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")
CodePudding user response:
Use the bycolors
argument of the binsreg
function:
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")
Created on 2022-03-14 by the reprex package (v2.0.1)