【问题标题】:Stacked Bar Chart Issues with ggplotggplot的堆积条形图问题
【发布时间】:2020-10-27 18:20:08
【问题描述】:

非常感谢为单个 x 值创建堆叠条形图的一些帮助。我在创建它时取得了一些成功,但是我想用我的 s 变量替换图表右侧的图例,并使颜色更加鲜明。参考图片。

d <- c(287, 76, 237, 44, 249, 149, 3)

s <- c('Allied servicemen reached Spain through the Pyrenees', 
'Civilians reached Spain through the Pyrenees', 
'Airmen who were arrested during their evasion', 
'Airmen who were handed over to other evasion lines', 
'Airmen who were kept in camps of the "Operation Marathon" in France and Belgium', 
'Airmen who were hidden by their lodgers until Liberation', 
'Airmen who were killed during their evasion')

t <- c('Comete Line','Comete Line','Comete Line',
'Comete Line','Comete Line','Comete Line','Comete Line')

Comete_Line <- data.frame(d,s,t)

Comete_Line <- Comete_Line[order(Comete_Line$d),]

Comete_Line.TB %>% 
ggplot(aes(x = t, y = d, fill = d)) + 
geom_bar(stat = "identity", width = 0.2)

【问题讨论】:

    标签: r ggplot2 bar-chart stacked-chart


    【解决方案1】:

    我想你只需要:

        Comete_Line %>% 
          ggplot(aes(x = t, y = d, fill = s)) + 
          geom_bar(stat = "identity", width = 0.2)
    

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-19
    • 2021-01-17
    • 1970-01-01
    • 2016-06-29
    相关资源
    最近更新 更多