title: Box plot of two groups add regression line to each group
body: <p>I want to make a graph that graphs box plots for two groups and adds a regression line for each group. I have seen a few examples available, but none achieving my goal. </p>
  
  <p>My dataframe is like so:</p>
  
  <pre><code>df&lt;- data.frame(cont.burnint= c(rep(2,10), rep(12, 10), rep(25, 10)), 
                    variable= rep(c("divA","divC"), 30), 
                    value= sample(x = seq(-1,4,0.5), size = 60, replace = 
                     TRUE))
  </code></pre>
  
  <p>I would like to produce a graph like: <a href="https://i.stack.imgur.com/T0CKz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T0CKz.png" alt="enter image description here"></a></p>
  
  <p>However, I want to change the points to a box plot for each group. I have not found helpful examples in the following:</p>
  
  <p><a href="https://stackoverflow.com/questions/34608767/add-geom-smooth-to-boxplot">Add geom_smooth to boxplot</a>
  <a href="https://stackoverflow.com/questions/10911057/adding-a-simple-lm-trend-line-to-a-ggplot-boxplot">Adding a simple lm trend line to a ggplot boxplot</a></p>
  
  <p>The code I have found available thus far, changes my continuous variable <code>cont.burnint</code> to a factor and reorders the x-values from c(2,12,25) to c(12,2,25). Also, the regression lines in the ggplot examples (refer to link)do not extend to the y axis. I would like the regression line to extend to the y-axis. Thirdly, the box plots become off set from each other and I would like an option that keeps the box plot for both groups on the same x value. </p>
  
  <p>So basically, I want to change the points in the graph provided to a box and whisker plot  and keep all else the same, in the example above. I wouldn't mind adding a legend below the plot and making text and lines bolder too. </p>
  
  <p>Here is the code for the example above:</p>
  
  <pre><code> plot(as.numeric(as.character(manovadata$cont.burnint)),manovadata$divA,type="p",col="black", xlab="Burn Interval (yr)", ylab="Interaction Diveristy", bty="n", cex.lab=1.5)
  
  points(as.numeric(as.character(manovadata$cont.burnint)),manovadata$divC,col="grey")
  
  abline(lm(manovadata$divA~as.numeric(as.character(manovadata$cont.burnint)), manovadata),col="black",lty=1)
  
  abline(lm(manovadata$divC~as.numeric(as.character(manovadata$cont.burnint)), manovadata),col="grey",lty=1)
  </code></pre>