垂直和水平條形圖
ggplot(data = diamonds, aes(x = cut, fill =color)) +
geom_bar(stat = "count", position = "dodge")
只需在 ggplot 物件中新增 coord_flip()
美學,就可以獲得水平條形圖:
ggplot(data = diamonds, aes(x = cut, fill =color)) +
geom_bar(stat = "count", position = "dodge")+
coord_flip()