0

enter image description here

ggplot(data=Test, aes(x=Year, y=Value, color = Factor)) + 
    geom_point(size=2, shape=22) + 
    geom_smooth(method='lm') +
    scale_y_continuous(breaks=c(1,50, 100, 150, 200, 250, 300, 365)) +
    scale_x_continuous (breaks = Test$Year) +
    theme(axis.text.x = 
          element_text(color = "grey20", size = 10, angle = 0, 
                       hjust = .5, vjust = .5, face = "bold"),
        axis.text.y = 
          element_text(color = "grey20", size = 10, angle = 0, 
                       hjust = .5, vjust = .5, face = "bold"))

This is the code which I used to generate the attached graph having regression lines for two groups (FALL and Spring). As the data is huge (1910 rows), I am not pasting it here. I would like to generate 'y=mx+c' equation for both groups and annotate the graph with the same. May I know how can I proceed?

January
  • 16,320
  • 6
  • 52
  • 74
Rahul
  • 33
  • 5
  • 1
    You may ;-) however, please do us a favor and do generate some example data. Post here the code to load this example data (either the R commands for generating example data, or using `dput`). See [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) and [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1). – January Nov 14 '22 at 06:27
  • Thanks @January for the comment. I will improve the post. And, I am so happy to let you know that I got a working solution from this post and it worked well (https://stackoverflow.com/questions/59018156/position-of-two-regression-equations-ggplot-r). I am really thankful. – Rahul Nov 14 '22 at 13:42

0 Answers0