Load necessary libraries and import data

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
# Data for the chart
years <- c(2018, 2019, 2020, 2021, 2022, 2023)
uget <- c(27, 23, 28, 29, 36, 25)
ugte <- c(49, 45, 52, 37, 49, 49)
others <- c(24, 32, 20, 22, 27, 26)

# Create a data frame
data <- data.frame(
  Year = rep(years, times=3),
  Share = c(uget, ugte, others),
  Group = rep(c("UGET", "UGTE", "Others"), each=length(years))
)

Create the plot

# Create the plot
ggplot(data, aes(x=Year, y=Share, color=Group)) +
  geom_line(size=1.5) +
  geom_point(size=3) +
  geom_text(aes(label=paste0(Share, "%")), vjust=-0.8, size=3.5) +
  scale_color_manual(values=c("UGET"="darkred", "UGTE"="darkgreen", "Others"="darkgray")) +
  labs(title="Results of the elections of student representatives",
       x="Year",
       y="Share of seats",
       color=NULL,  # Remove the legend title
       subtitle="Source: MHESR, Visualization:M.D.Hammami") +
  theme_minimal() +
  theme(plot.caption = element_text(hjust=0),
        plot.title = element_text(hjust=0.5),
        legend.position = "top")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Save the plot
ggsave("election_results.png", width = 10, height = 6)