Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

show equation using geom_smooth

library(ggpmisc)
df <- data.frame(x = c(1:100))
df$y <- 20 * c(0, 1) + 3 * df$x + rnorm(100, sd = 40)
df$group <- factor(rep(c("A", "B"), 50))
my.formula <- y ~ x
p <- ggplot(data = df, aes(x = x, y = y, colour = group)) +
  geom_smooth(method = "lm", se=FALSE, formula = my.formula) +
  stat_poly_eq(formula = my.formula, 
               aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), 
               parse = TRUE) +         
  geom_point()
p

p <- ggplot(data = df, aes(x = x, y = y, linetype = group)) +
  geom_smooth(method = "lm", se=FALSE, formula = my.formula) +
  stat_poly_eq(formula = my.formula, 
               aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), 
               parse = TRUE) +         
  geom_point()
p
Comment

PREVIOUS NEXT
Code Example
Python :: apply same shuffle to two arrays numpy 
Python :: how to fill nan values in pandas 
Python :: inverse list python 
Python :: std python 
Python :: python convert string to byte array 
Python :: delete dictionary key python 
Python :: python print variables and string 
Python :: python string indexof 
Python :: jpython 
Python :: find the time of our execution in vscode 
Python :: how to find last index of list in python 
Python :: change xlabel rotate in seaborn 
Python :: render django 
Python :: get variable name python 
Python :: print current line number python 
Python :: How to split a text column into two separate columns? 
Python :: color python 
Python :: copy website python 
Python :: python lambda function map 
Python :: python count code, Count number of occurrences of a given substring 
Python :: python collections Counter sort by key 
Python :: how to save an image with the same name after editing in python pillow module 
Python :: Adding function to a varieble in python 
Python :: python location 
Python :: loop throughthe key and the values of a dict in python 
Python :: python expressions 
Python :: python cmd exec 
Python :: pdf to csv 
Python :: remove ,drop,effacer, dataframe,python 
Python :: check if a list contains any item from another list python 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =