stat_regline_equation: Polynomial Equation not showing

I am not getting the equation detail in my plot.
Would you please suggest if any corrections needed to show the Polynomial Equation.

Please note that no error message is showing.

My Codes:

ggplot(Sales, aes(Date, Price))+
geom_point(size=3, shape=16, color = 'green')+
geom_smooth(aes(color = "3rd Order Trend"), method = "lm", formula = y~poly(x,3), se = F) +
coord_cartesian(ylim = c(0, 550)) +
scale_color_manual(values = c("Linear Trend" = "blue", "3rd Order Trend" = "red"), name=NULL) +
stat_regline_equation(
aes(label = paste(..eq.label.., ..adj.rr.label.., sep = "~~~~")),
formula = y~poly(x,3), se = F
)+
labs(title = "Retail Price Trend", x = "Sale Date", y = "Sales Price/s.f.")

> dput(head(Sales))
structure(list(Date = structure(c(1298937600, 1330560000, 1333238400,
1335830400, 1335830400, 1351728000), tzone = "UTC", class = c("POSIXct",
"POSIXt")), Price = c(47.57, 35.79, 1022.42, 91.27, 67.2, 73.24
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"

Thank you!

in the future when you use functions from non-tidyverse packages, please state what they are; this reduces the research efforts of those who would help you. in this case you are relying on library(ggpubr)

  coord_cartesian(ylim = c(0, 550)) +

The statistic was printed out of the bounds of this limit;
you can adjust the position that the equation is placed; like so.

 stat_regline_equation(
    aes(label = paste(after_stat(eq.label), after_stat(adj.rr.label), sep = "~~~~")),
    formula = y~poly(x,3),
    label.y=550/2
  )

specifically in this case the label.y value

this is noted nirgrahamuk. the issue is solved. Thank you so much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.