I use one public datasets for plot.
x1 <- data.frame(
primary = c("結腸、直腸、乙狀結腸連結部及肛門", "肝及肝內膽管", "肺、支氣管及氣管", "口腔、口咽及下咽", "攝護腺", "食道", "胃", "皮膚", "膀胱", "白血病"),
number = c(9434 ,7800, 7936, 7058, 5866, 2563, 2304, 2089, 1707, 1383),
gender = rep("M",10))
# reorder the primary with number
x1 <- x1 %>% mutate(primary = fct_reorder(primary, number))
ggplot(x1, aes(primary, number)) +
geom_col(color ="blue") +
geom_text(aes(label = number)) +
coord_flip()
The names of item on x-axis is too long; thus I use str_wrap as suggested
ggplot(x1, aes(str_wrap(primary, 8), number)) +
geom_col(color ="blue") +
geom_text(aes(label = number)) +
coord_flip()
The names become beautiful, but the order of columns is out
I google it and read the suggested topic by system. I can not find the way to solve it. I hope someone can help me. Thanks a lot.