I have managed to smooth the line of my graph thanks to "geom_xspline" of ggalt, but at the time of connecting the there is an excess of curvature that can cause a misinterpretation of my graph . For example the point of the year 2019 the count is "26.9%" should be at the top of the curve but was below, which implies that there were higher values than "26.9%" something that is not true.
The result I would like to achieve is the following
. As you can see, each point fits perfectly to the top of the curve.
I have tried setting "spline_shape = -0.2" which partly achieves what I am looking for, but gives a square look to the line. So, I appreciate any help in solving this problem, thank you very much.
library(ggalt)
AÑO <- seq(2004,2023, by = 1)
No_ejecutado <- c(10.2 , 5.2, 5.4 , 4.0 , 6.6 , 3.8 , 4.1, 15.3, 11.1, 12.1 ,10.1, 12.9 ,19.8, 17.2 ,22.4 ,26.1 ,26.9 , 9.3,
8.7 ,7.3 )
Congreso_12 <- data.frame(AÑO,No_ejecutado)
no_ejecucion <- ggplot(Congreso_12, aes(AÑO,No_ejecutado, group = 1) )+
geom_xspline( position = position_jitter(),spline_shape=-0.5,color = "#2FC1D3")+
aes(lwd = 1.5)+
scale_linewidth_identity()+
geom_point(
fill ="#2FC1D3",
size = 4,
pch = 21,
color = "white",
stroke = 1
)+
scale_x_continuous(breaks = seq(2004,2023,by = 1))+
geom_text(
data= Congreso_12,
aes(x = AÑO, y = No_ejecutado, label = paste0(round(No_ejecutado,3),"%")), #aca no dividimos porque esta en cifras bajas
family = "avenir",
fontface = "bold",
size = 4,
nudge_y = 0.4,
)
no_ejecucion