This does not work:
# example
x = np.linspace(0, 1, 100)
y = np.random.binomial(1, 0.5, 100)
dat = pd.DataFrame({"x": x, "y": y})
ggplot(dat, aes(x="x", y="y")) + geom_point() + geom_smooth(method="glm", method_args={"family": "binomial"})
Returns AttributeError: 'str' object has no attribute 'link'
The analogue in R works like:
library(ggplot2)
x <- seq(0, 1, length=100)
y <- rbinom(100, 1, 0.5)
dat <- data.frame(x=x, y=y)
ggplot(dat, aes(x=x, y=y)) + geom_point() + geom_smooth(method="glm", method.args=list(family="binomial"))
Info:
- plotnine: 0.10.1
- python: 3.10.2