title: dynamic conditional colors ggplot for geom_bar
body: <p>I have data that varies for different companies who may have different numbers of relevant "measures".  If a measure falls below the benchmark, it should be colored a certain color which I've set to pink.  If a measure is above the benchmark, it should be colored blue.  The problem is, different companies have different numbers of measures and these measures could be lower or higher than the benchmark; there is no pattern.</p>
  
  <p>I am using this condition in fill and it works sometimes.</p>
  
  <pre><code>ggplot(df, aes(measure)) + geom_col(aes(y=company, fill=overall &gt; company)) + geom_point(aes(y=overall, color="overall"), size=8, shape=124) +
    scale_color_manual("",values=c("company" = "yellow", "overall"="blue"),labels=c("company" = "Your Company", "overall"= "Overall Benchmark")) +
    coord_flip()+ guides(size=FALSE) + theme(legend.box="horizontal",legend.key=element_blank(), legend.title=element_blank(),legend.position="top") +
    scale_fill_manual(values=c("lightblue2", "lightpink2"),labels=c("Better","Worse"))
  </code></pre>
  
  <p>But for example if the data frame looks like this, it's completely off:</p>
  
  <pre><code> df = data.frame(
        measure = c("Measure A","Measure B","Measure C","Measure D"),
        overall = c(9, 5, 11, 19),
        company = c(4,3,7, 16)
      )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Hx2pq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hx2pq.png" alt="enter image description here"></a></p>
  
  <p>If the data frame looks like this, it's fine: </p>
  
  <pre><code>df2 = data.frame(
    measure = c("Measure A","Measure B", "Measure C"),
    overall = c(9, 5, 11),
    company = c(11,7, 9)
  )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/r9vYa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r9vYa.png" alt="enter image description here"></a></p>
  
  <p>I think this method doesn't accurately color the bars but I'm not sure why exactly.</p>