Can someone please let me know how i can add dashed lines (from both x and y-axis) cutting data point at specific point. I also attached an example:
Here is my code:
library(ggplot2)
library(ggpmisc)
#> Warning: package 'ggpmisc' was built under R version 4.0.3
#>
#> Attaching package: 'ggpmisc'
#> The following object is masked from 'package:ggplot2':
#>
#> annotate
df <- read.csv("F:/Complete_Projects/cutoff_example.csv", stringsAsFactors = F)
colnames(df)[1] = "timedata"
colnames(df)[2] = "score"
ggplot(df, aes(x = timedata, y = score)) +
theme_bw() +
xlab("Storage time (Months)") +
ylab("Staleness intensity on 15-point scale") +
geom_point(color = "#04fbfb", size = 2) +
geom_smooth(method=lm, linetype = "dashed", color="black") +
coord_cartesian(ylim=c(1, 9)) +
scale_y_continuous(breaks=seq(1, 9, 1)) +
stat_poly_eq(formula = y ~ x,
aes(label = paste(..eq.label..)),
parse = TRUE, label.y = 0.60) +
stat_poly_eq(formula = y ~ x,
aes(label = paste(..rr.label..)),
parse = TRUE, label.y = 0.55) +
theme(axis.title.x = element_text(face = "bold"),
axis.title.y = element_text(face="bold"),
axis.text.x= element_text(face = "bold"),
axis.text.y = element_text(face = "bold"),
panel.border = element_blank(),
axis.line = element_line())
#> `geom_smooth()` using formula 'y ~ x'