0

I'm trying to create a combination graph using ggplot2. I would like the graph to look similar to the one below but I don't want the secondary axis, nor do I want the "series 2" showing up in the legend.

Right now I can create a combination graph, see code and data example below, but the issue I'm running into is that my y-axis splits into two different units (0000s and %). I would like to ask for any suggestions that would allow me to display my graph with the y axis reflecting just the Score values and the WARate value to show up as values below the graphed line, within the plot area.

df <- data.frame(
  Type=c("A","A","A","B","B","B"),
  Quarter=c("Q1","Q2","Q3","Q1","Q2","Q3"),
  Score=c("1360","1330","1345","1200","1215","1230"),
  WARate=c('4%','3.41%','3.39%','4%','3.41%','3.39%')
)
    
df %>% 
  group_by((Quarter)) %>%
  ggplot(aes(x=(Quarter), y=Score,fill=Type)) +
    geom_bar(stat = "identity") +
    geom_text(aes(label = format(round(stat(y),0),big.mark=","), group = Quarter), 
        stat = 'summary', fun = sum, vjust = -.25) +
    geom_line(aes(x=Quarter,y=WARate,group = 1))

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295
a_js12
  • 329
  • 1
  • 8

0 Answers0