title: Assign colors to negative and positive values in R barplot
body: <p>I'm trying to replicate a time series barplot figure of a climate index (NPO, specifically) where there are different colors for positive and negative values.</p>
  <p><a href="https://i.stack.imgur.com/aQ5El.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aQ5El.png" alt="enter image description here" /></a></p>
  <p>I'm using a different index, so the values are different but the concept is the same. the data are <a href="http://www.o3d.org/npgo/npgo.php" rel="nofollow noreferrer">here</a> (I don't know how to link a dataset you can import? Sorry for the inconvenience)</p>
  <p>I've attempted ggplot and the zoo package to restructure the data:</p>
  <pre><code>library(tidyverse)
  library(here)
  library(zoo)
  NPGO &lt;- read_csv(here('data//NPGOindex_toJuly2020.csv'))
  NPGO &lt;- rename(NPGO, index=`NPGO index`)
  glimpse(NPGO)
  NPGO$DATE &lt;- as.yearmon(paste(NPGO$YEAR, NPGO$MONTH), '%Y %m')
  NPGO$color &lt;- ifelse(NPGO$index&lt;0, 'negative','positive')
          
  ggplot(NPGO, aes(x=DATE, y=index)) +
         geom_bar(stat='identity',
                  width=0.8, aes(fill=color)) +
         scale_x_yearmon(format='%m %Y', expand=c(0,0)) +
         scale_fill_manual(values=c(positive='red',negative='blue')) +
         geom_line(aes(y=0), color='black') + theme_bw()
  </code></pre>
  <p>Though I end up with these stacked bars, not sequential:
  <a href="https://i.stack.imgur.com/lXhga.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lXhga.png" alt="enter image description here" /></a></p>
  <p>base <code>barplot()</code> produces more what I am looking for and I attempted to use the code that <a href="https://stackoverflow.com/questions/24112734/conditional-barchart-coloring-with-a-vector-in-r">seemingly answered my question</a>, but no dice:</p>
  <pre><code>barplot(height=NPGO$index,
      col=ifelse(NPGO$index&gt;0,'red','blue'))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xBoMX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xBoMX.png" alt="enter image description here" /></a></p>
  <p>Any help would be very appreciated, thanks!</p>