I have this df:
structure(list(Year = c(2021, 2020, 2019, 2018, 2017, 2016, 2015,
2014), Age = c(47.6, 47.29, 46.93, 46.58, 46.17, 45.66, 45.31,
44.96)), row.names = c(NA, -8L), class = c("tbl_df", "tbl", "data.frame"
))
With this code I want to make a line chart, I obtain this:
I want that minor y lines appears on 44, 45, 46, 47 and 48 breaks, not overhead:
ggplot(df) +
aes(x = Year, y = Age) +
geom_text(aes(label = Age), vjust = -1.3, hjust = 0.8) +
geom_line(linewidth = 1.96, colour = "#2171b5") +
scale_y_continuous(limits = c(44,48), breaks = c(44, 45, 46, 47, 48)) +
scale_x_continuous(breaks = seq(2014,2021,1)) +
theme_minimal() +
theme(plot.subtitle = element_text(size = 12, hjust = 0.5),
plot.caption = element_text(size = 10),
panel.grid.major = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_line(linewidth = 1.1),
axis.ticks = element_line(linetype = "blank"),
axis.title = element_text(size = 15),
axis.text = element_text(size = 10),
plot.title = element_text(color = "#2171b5", size = 20, face = "bold", hjust = 0.5),
legend.title = element_text(size = 8),
legend.position = "left") + labs(x = NULL, y = NULL)