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

adjustable spacing in vertically aligned equations for `stat_poly_eq()` #62

Closed wbvguo closed 3 months ago

wbvguo commented 3 months ago

Hi, thanks for your support

The vertically aligned equations tend to overlap if the plot width/height is small. I was wondering if there is a way to increase the spacing between vertically stacked equations?

mpg %>% ggplot(aes(x = cty, y = hwy, colour = drv)) +
    geom_point(alpha = 0.5) +
    geom_smooth(method=lm , se=FALSE) +
    geom_abline(intercept = 0, slope = 1, linetype = 3) + 
    stat_poly_eq(use_label(c("eq", "R2")), coef.digits = 3)

image

Thanks!

aphalo commented 3 months ago

@wbvguo Yes, pass an argument to parameter vstep. Values are in NPC.

mpg |> ggplot(aes(x = cty, y = hwy, colour = drv)) +
  geom_point(alpha = 0.5) +
  geom_smooth(method=lm , se=FALSE) +
  geom_abline(intercept = 0, slope = 1, linetype = 3) + 
  stat_poly_eq(use_label(c("eq", "R2")), coef.digits = 3, vstep = 0.1)
wbvguo commented 3 months ago

Thanks! close this issue now.