aphalo / ggpmisc

R package ggpmisc is an extension to ggplot2 and the Grammar of Graphics
https://docs.r4photobiology.info/ggpmisc
94 stars 6 forks source link

Spacing of "text" output in `stat_poly_eq()` #26

Closed aphalo closed 1 year ago

aphalo commented 2 years ago

The spacing of "text" output in stat_poly_eq() could be improved. Possibly, best is not to include the asterisk.

See question at Stackoverflow. The code below could work as a possible answer.

df <- data.frame(x = c(1:100))
df$y <- 20 + 30 * df$x + rnorm(100, sd = 80)

library(ggpmisc)
#> Loading required package: ggpp
#> Loading required package: ggplot2
#> 
#> Attaching package: 'ggpp'
#> The following object is masked from 'package:ggplot2':
#> 
#>     annotate

ggplot(df, aes(x, y)) + 
  geom_point() +
  stat_poly_line(method = "lm", se = FALSE) +
  stat_poly_eq(use_label(c("eq", "R2"), sep = ", "), output.type = "text") 

Created on 2022-09-06 with reprex v2.0.2