![](/img/trans.png)
[英]order y axis by count of one particular value in column with geom_bar
[英]geom_bar of count plot: add x axis label for column with no value and customize order of remaining bars
我需要為以下數據中的空值計數添加 label:
library(ggplot2)
myData <- data.frame(
x = c("A", "A", "B", "B", "B", "C", "C", "C", "", "", "", ""),
y = c(1, 4, 1, 5, 1, 5, 6, 7, 3, 6, 6, 3)
)
ggplot(myData, aes(x=x)) +
geom_bar(width = 0.5)+
geom_text(stat='count', aes(label = ..count..), vjust = -1)
如何為第一列添加定制的 label? 說“不可用”
第二個問題,我需要自定義剩余條的順序,所以第一個條總是具有空值的條,但隨后,我想要按B, C, A
順序排列的條(不是降序或升序)。 其他 StackOverflow 答案似乎解決了基於計數的條形重新排序問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.