0
votes

I would much appreciate some help to create a stacked bar chart for a single x value. I have had some success creating it, however I would like to replace the legend on the right hand side of the graph with my s variable and make the colour more distinct. See image for reference.

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)

Image of chart as it stands

1

1 Answers

0
votes

I think you just need:

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

enter image description here