ggplot 的堆积条形图问题

Stacked Bar Chart Issues with ggplot

对于为单个 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)

我想你只需要:

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