看看这是否是您正在寻找的:
c %>% # process the variable values before passing the data frame to ggplot(), mutate(Medal = forcats::fct_relevel(Medal, "Gold", "Silver", "Bronze", "None"), region = forcats::fct_reorder(region, med_count)) %>% ggplot(aes(x = region, y = medals, fill = Medal)) + geom_col() + geom_text(aes(y = med_count, # position the label based on total medals per region label = med_count), hjust = 0, # left-align labels to total medal count # (default is central alignment) nudge_y = 5, # offset labels slightly to the right check_overlap = TRUE, # for three labels overlapping in the same position, # only plot the first one size=3) + # optional: a color palette that sort of rsembles the medal colours scale_fill_brewer(palette = "BrBG") + coord_flip()