A minimum working example code:
df <- data.frame()
df[1:2,"year"] <- 2012L
df[3:7, "year"] <- 2013L
df[8:16, "year"] <- 2014L
df$team <- c("Team_A", "Team_B", "Team_A", "Team_B", "Team_C",
"Team_D", "Team_E", "Team_A", "Team_B", "Team_C",
"Team_D", "Team_E", "Team_F", "Team_G", "Team_H",
"Team_I")
df$matches <- c(4, 2, 9, 7, 3, 4, 1, 16, 13, 10, 8, 9, 2,3,1, 3)
df
The dataframe looks like this:
year team matches
1 2012 Team_A 4
2 2012 Team_B 2
3 2013 Team_A 9
4 2013 Team_B 7
5 2013 Team_C 3
6 2013 Team_D 4
7 2013 Team_E 1
8 2014 Team_A 16
9 2014 Team_B 13
10 2014 Team_C 10
11 2014 Team_D 8
12 2014 Team_E 9
13 2014 Team_F 2
14 2014 Team_G 3
15 2014 Team_H 1
16 2014 Team_I 3
The matches are plot yearwise:
match_plot_yearwise <- ggplot(df, aes(matches, team, color = year)) +
geom_segment(aes(x = matches, y = team, xend = matches, yend = team),
color= "grey50") +
geom_point() +
theme_minimal() +
theme(
panel.grid = element_blank(),
)
match_plot_yearwise
This gives the following plot:

If a team plays more than one year then, how to repeat the team name on y-axis that many times, instead of stacking it's each year match one above the other?
