ggplot2: How to conditionally change geom_text's vjust when low bars make text exceed bar's bottom
问题 When plotting a bar chart, I often add labels to bars to signify the y-value for each bar. However, I run into trouble when the bar becomes too low, making the label unreadable or simply ugly. Example library(ggplot2) df_blood <- data.frame(blood_type = c("O-", "O+", "A-", "A+", "B-", "B+", "AB-", "AB+"), frequency = c(0.13, 0.35, 0.08, 0.3, 0.02, 0.08, 0.01, 0.02)) ggplot(df_blood, aes(x = blood_type, y = frequency, fill = blood_type)) + geom_bar(stat = "identity") + geom_text(aes(label =