R stat_regline_equation doesn't match stat_smooth line
12:42 05 Nov 2025

I'm getting an odd problem where I've attempted to plot a scatter graph and fit a quadratic regression line to it. I used stat_smooth() to make the line and stat_regline_equation() to print the equation but the equation that appears doesn't match the line.

Why could this be?

Here is the scatter plot with a quadratic regression line fitted and an equation that does not match the line

Here's a demo of the code I'm using:

#LIBRARIES
library(tidyverse)
library(ggpubr)
library(ggplot2)

test_db <- data.frame(
  X = c(0,-0.1297,-0.2185,-0.2795),
  Y = c(0.7569,0.7396,0.6561,0.5476)
  )


test_plot = ggscatter(test_db, x = "X", y = "Y",
                       xlim = c(-1,0),
                       ylim = c(0, 1),
                       fill = "red",
                       shape = 23
)+
  stat_regline_equation(label.x = -0.95, label.y = 0.15,  #print equation for regression line
                        formula = y ~ poly(x, 2),         #set regression line as quadratic
                        show.legend=FALSE,
  )+
  stat_smooth(method = "lm",               #plot smoothed conditional mean
              formula = y ~ poly(x, 2),    #set regression line as quadratic
              colour="black", size=0.5,
              fill="red"
              ) + 
  theme_bw() + 
  labs(x = "X", 
       y = "Y",
       title = "Test plot")
test_plot
r plot linear-regression