Hello everyone!
I am trynig to plot a correlation graf using ggplot2, this plot contains 3 geom_abline: (0,1), (intercepet, slope from regression1) and (intercepet, slope from regression2)
I used this script before and worked well, but now the regression abline just appears when I used limits including de intercept value, but I'd like the graph to be from 0, like this:
Can someone help me please?
Here is the code:
dat_ap <- tibble(clone = c("3334", "3334", "3334", "3334", "3334",
"3334", "3334", "3334", "3334", "3334", "3334", "3334", "3334",
"3334", "3334", "3334", "3334", "3334", "3334", "3336", "3336",
"3336", "3336", "3336", "3336", "3336", "3336", "3336", "3336",
"3336", "3336", "3336", "3336", "3336", "3336", "3334", "3334",
"3334", "3334", "3334", "3334", "3334", "3334", "3334", "3334",
"3334", "3334", "3334", "3334", "3334", "3334", "3334", "3334",
"3334", "3334", "3336", "3336", "3336", "3336", "3336", "3336",
"3336", "3336", "3336", "3336", "3336", "3336", "3336", "3336",
"3336", "3336", "3336", "3336", "3336"),
ap_observado = c(1.87088777834092,
1.87088777834092, 1.87088777834092, 1.87088777834092, 1.87088777834092,
1.87088777834092, 1.87088777834092, 1.87088777834092, 1.87088777834092,
1.87088777834092, 1.87088777834092, 1.87088777834092, 1.87088777834092,
1.87088777834092, 1.87088777834092, 1.87088777834092, 1.87088777834092,
1.87088777834092, 1.87088777834092, 3.93549287158548, 3.93549287158548,
3.93549287158548, 3.93549287158548, 3.93549287158548, 3.93549287158548,
3.93549287158548, 3.93549287158548, 3.93549287158548, 3.93549287158548,
3.93549287158548, 3.93549287158548, 3.93549287158548, 3.93549287158548,
3.93549287158548, 3.93549287158548, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439, 1.70473923969439, 1.70473923969439, 1.70473923969439,
1.70473923969439),
ap_est_ori = c(1.90126340639215, 1.90126340639215,
1.90126340639215, 1.93943629438848, 1.93943629438848, 1.93943629438848,
1.93943629438848, 1.89455257305711, 1.89455257305711, 1.89455257305711,
1.89455257305711, 1.93943629438848, 1.93943629438848, 1.93943629438848,
1.93943629438848, 1.93943629438848, 1.93943629438848, 1.93943629438848,
1.93943629438848, 3.82807809491712, 3.82807809491712, 3.82807809491712,
3.82807809491712, 3.82807809491712, 3.82807809491712, 3.82807809491712,
3.82807809491712, 3.82807809491712, 3.82807809491712, 3.82807809491712,
3.82807809491712, 3.76201958880157, 3.76201958880157, 3.76201958880157,
3.76201958880157, 1.79630504324139, 1.79630504324139, 1.79630504324139,
1.79630504324139, 1.80187056933036, 1.80187056933036, 1.80187056933036,
1.80187056933036, 1.79630504324139, 1.79630504324139, 1.79630504324139,
1.79630504324139, 1.80187056933036, 1.80187056933036, 1.80187056933036,
1.80187056933036, 1.80587504705132, 1.80587504705132, 1.80587504705132,
1.80587504705132, 1.79630504324139, 1.79630504324139, 1.79630504324139,
1.80187056933036, 1.80187056933036, 1.80187056933036, 1.80187056933036,
1.80187056933036, 1.80187056933036, 1.80187056933036, 1.80187056933036,
1.80187056933036, 1.80187056933036, 1.80187056933036, 1.80187056933036,
1.80187056933036, 1.80187056933036, 1.80187056933036, 1.80187056933036))
ap_F4 <- c(3.055039e+02, 1.492271e-24)
ap_r4 <- 0.9736638
ap_rq4 <- 4.437326
ap_F6 <- c(4.263299e+02, 2.672239e-25)
ap_r6 <- 0.9998125
ap_rq6 <- 4.09155
cor_ap <- ggplot(data = dat_ap) +
geom_point(aes(x = ap_est_ori, y = ap_observado, color = clone), size = 6) +
geom_abline(intercept = 0, slope = 1, color = "black", size = 1.8) +
geom_abline(intercept = -0.5870776, slope = 1.275254, size = 1.5, linetype = "dashed", color = "#8B8282") +
geom_abline(intercept = -0.2923514, slope = 1.109096, size = 1.5, linetype = "dashed", color = "#836FFF") +
scale_x_continuous(expand = c(0,0), limits = c(0,7), labels = comma_format(decimal.mark = ",", accuracy = 1),name = "ap estimado") +
scale_y_continuous(expand = c(0,0), limits = c(0,7), labels = comma_format(decimal.mark = ",", accuracy = 1),name = "ap observado") +
scale_color_manual(values = c("#8B8282", "#836FFF")) +
#ggtitle(label = bquote(H[0]~":"~"["~beta[0]~~~beta[1]~"]"=="["~0~~~1~"]")) +
annotate(geom = "text", x = 2, y = 6.6, label = bquote(p-valor~(3334)==.(ap_F4[[2]])), size = 12) +
annotate(geom = "text", x = 2, y = 6, label = bquote(p-valor~(3336)==.(ap_F6[[2]])), size = 12) +
annotate(geom = "text", x = 1.7, y = 5, label = paste("r (3334) = ",round(ap_r4,8)), size = 12)+
annotate(geom = "text", x = 1.7, y = 4.3, label = paste("r (3336) = ",round(ap_r6,8)), size = 12)+
annotate(geom = "text", x = 4, y = 2, label = paste("RQEM(%) (3334) =",round(ap_rq4,1)), size = 12)+
annotate(geom = "text", x = 4, y = 1, label = paste("RQEM(%) (3336) =",round(ap_rq6,1)), size = 12)+
theme_classic()+
theme(legend.position=c(0.9,.25),
legend.title = element_text(size = 40),
legend.text = element_text(size = 40),
panel.grid.minor = element_line(size = 0.5),
axis.ticks.length = unit(0.3, "cm"),
axis.ticks = element_line(size = 1),
axis.line = element_line(size = 1.8),
plot.title = element_text(size = 40, face = "bold"),
axis.title = element_text(size = 40, color = "black"),
axis.text = element_text(size = 40, color = "black")); cor_ap