1

I have been trying to get the following code, which produces Image 1, to look like Image 2, I would very much appreciate any help!

barchart = ggplot(
  data = Final_tank, 
  aes(x = Lookback, y = Return, fill = Type)) +
geom_bar(aes(fill = Type), position = "dodge", stat="identity") + 
guides(
  fill = guide_legend(
    reverse = FALSE, 
    keywidth = 2, 
    keyheight = 2,
    nrow = nrow(Final_tank),
    labels = Final_tank$Category, 
    title = (NULL))) +  
scale_fill_manual(values = c("#002142", "#e8a823", "#afafaf")) +  
scale_y_continuous(labels = percent)

Image 1 enter image description here

Image 2 enter image description here

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
agross144
  • 11
  • 1

1 Answers1

0

For the x-axis to show up in the order you want it to, you'll have to modify the data:

data %>% mutate(Lookback = fct_relevel(Lookback, c("Since Inception", "5 Year", ...)

For the rest:

+    
geom_text(aes(label = Return,
                      y = Return+0.015, x=Lookback),
                  size = 3, position = position_dodge(width=0.9)) +
        scale_y_continuous(labels = percent)+
        theme_bw()
Arthur Yip
  • 5,810
  • 2
  • 31
  • 50