<p dir="auto">I am trying to do a barplot where the positive values are a certain color and the negative values are another color.  I have scripts that I've used in previous versions where this was working but the current version isn't working.  I am basing it off of a code snippet from: <a href="https://stackoverflow.com/questions/22311139/matplotlib-bar-chart-choose-color-if-value-is-positive-vs-value-is-negative" rel="nofollow">https://stackoverflow.com/questions/22311139/matplotlib-bar-chart-choose-color-if-value-is-positive-vs-value-is-negative</a></p>
<p dir="auto"><strong>Is there something in the backend of the plotting wrapper that is stoping multiple color values from working?</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Versions
print(&quot;Python Version:&quot;, sys.version)
print()
print(&quot;Pandas Version:&quot;, pd.__version__)

# Input Data
data = {'M00001': 0.099999999999999978, 'M00003': 0.125, 'M00004': -0.14200000000000007, 'M00005': -1.0, 'M00007': -0.25, 'M00017': 0.14300000000000002, 'M00021': -1.0, 'M00023': -0.25, 'M00034': 0.097000000000000003, 'M00035': -0.25, 'M00048': -0.122, 'M00050': -0.25, 'M00053': -0.125, 'M00060': 0.11099999999999999, 'M00063': -0.25, 'M00115': 0.59999999999999998, 'M00116': -0.11099999999999999, 'M00126': -0.14300000000000002, 'M00127': -0.39999999999999997, 'M00144': -0.15400000000000003, 'M00149': 0.25, 'M00157': -0.125, 'M00173': -0.090000000000000024, 'M00178': -0.17300000000000004, 'M00179': -0.10399999999999998, 'M00188': 0.33300000000000002, 'M00240': -0.33299999999999996, 'M00242': -0.33299999999999996, 'M00256': 0.5, 'M00335': -0.125, 'M00359': -0.050000000000000044, 'M00360': -0.05600000000000005, 'M00377': 0.14299999999999996, 'M00459': 0.5, 'M00481': 0.5, 'M00504': 0.5, 'M00527': 0.1429999999999999, 'M00530': -0.5, 'M00532': 0.10000000000000001, 'M00549': 0.66700000000000004, 'M00609': 0.16699999999999998, 'M00614': -0.083000000000000018, 'M00618': 0.11200000000000004, 'M00628': -0.25, 'M00695': -0.33300000000000002, 'M00723': -0.25, 'M00728': 0.33300000000000002, 'M00754': 0.33300000000000002, 'M00793': -0.25, 'M90000': -0.11400000000000005, 'M91000': -0.070000000000000007}
Se_data =  pd.Series(data)

# Pandas Plotting
with plt.style.context(&quot;seaborn-white&quot;):
    fig, ax = plt.subplots(figsize=(5,10))
    Se_data.plot(kind=&quot;barh&quot;, ax=ax, color=Se_data.map(lambda x: {True:&quot;blue&quot;, False:&quot;red&quot;}[x &gt; 0]))"><pre class="notranslate"><span class="pl-c"># Versions</span>
<span class="pl-en">print</span>(<span class="pl-s">"Python Version:"</span>, <span class="pl-s1">sys</span>.<span class="pl-s1">version</span>)
<span class="pl-en">print</span>()
<span class="pl-en">print</span>(<span class="pl-s">"Pandas Version:"</span>, <span class="pl-s1">pd</span>.<span class="pl-s1">__version__</span>)

<span class="pl-c"># Input Data</span>
<span class="pl-s1">data</span> <span class="pl-c1">=</span> {<span class="pl-s">'M00001'</span>: <span class="pl-c1">0.099999999999999978</span>, <span class="pl-s">'M00003'</span>: <span class="pl-c1">0.125</span>, <span class="pl-s">'M00004'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.14200000000000007</span>, <span class="pl-s">'M00005'</span>: <span class="pl-c1">-</span><span class="pl-c1">1.0</span>, <span class="pl-s">'M00007'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00017'</span>: <span class="pl-c1">0.14300000000000002</span>, <span class="pl-s">'M00021'</span>: <span class="pl-c1">-</span><span class="pl-c1">1.0</span>, <span class="pl-s">'M00023'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00034'</span>: <span class="pl-c1">0.097000000000000003</span>, <span class="pl-s">'M00035'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00048'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.122</span>, <span class="pl-s">'M00050'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00053'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.125</span>, <span class="pl-s">'M00060'</span>: <span class="pl-c1">0.11099999999999999</span>, <span class="pl-s">'M00063'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00115'</span>: <span class="pl-c1">0.59999999999999998</span>, <span class="pl-s">'M00116'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.11099999999999999</span>, <span class="pl-s">'M00126'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.14300000000000002</span>, <span class="pl-s">'M00127'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.39999999999999997</span>, <span class="pl-s">'M00144'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.15400000000000003</span>, <span class="pl-s">'M00149'</span>: <span class="pl-c1">0.25</span>, <span class="pl-s">'M00157'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.125</span>, <span class="pl-s">'M00173'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.090000000000000024</span>, <span class="pl-s">'M00178'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.17300000000000004</span>, <span class="pl-s">'M00179'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.10399999999999998</span>, <span class="pl-s">'M00188'</span>: <span class="pl-c1">0.33300000000000002</span>, <span class="pl-s">'M00240'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.33299999999999996</span>, <span class="pl-s">'M00242'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.33299999999999996</span>, <span class="pl-s">'M00256'</span>: <span class="pl-c1">0.5</span>, <span class="pl-s">'M00335'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.125</span>, <span class="pl-s">'M00359'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.050000000000000044</span>, <span class="pl-s">'M00360'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.05600000000000005</span>, <span class="pl-s">'M00377'</span>: <span class="pl-c1">0.14299999999999996</span>, <span class="pl-s">'M00459'</span>: <span class="pl-c1">0.5</span>, <span class="pl-s">'M00481'</span>: <span class="pl-c1">0.5</span>, <span class="pl-s">'M00504'</span>: <span class="pl-c1">0.5</span>, <span class="pl-s">'M00527'</span>: <span class="pl-c1">0.1429999999999999</span>, <span class="pl-s">'M00530'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.5</span>, <span class="pl-s">'M00532'</span>: <span class="pl-c1">0.10000000000000001</span>, <span class="pl-s">'M00549'</span>: <span class="pl-c1">0.66700000000000004</span>, <span class="pl-s">'M00609'</span>: <span class="pl-c1">0.16699999999999998</span>, <span class="pl-s">'M00614'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.083000000000000018</span>, <span class="pl-s">'M00618'</span>: <span class="pl-c1">0.11200000000000004</span>, <span class="pl-s">'M00628'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00695'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.33300000000000002</span>, <span class="pl-s">'M00723'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M00728'</span>: <span class="pl-c1">0.33300000000000002</span>, <span class="pl-s">'M00754'</span>: <span class="pl-c1">0.33300000000000002</span>, <span class="pl-s">'M00793'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.25</span>, <span class="pl-s">'M90000'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.11400000000000005</span>, <span class="pl-s">'M91000'</span>: <span class="pl-c1">-</span><span class="pl-c1">0.070000000000000007</span>}
<span class="pl-v">Se_data</span> <span class="pl-c1">=</span>  <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">data</span>)

<span class="pl-c"># Pandas Plotting</span>
<span class="pl-k">with</span> <span class="pl-s1">plt</span>.<span class="pl-s1">style</span>.<span class="pl-en">context</span>(<span class="pl-s">"seaborn-white"</span>):
    <span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">5</span>,<span class="pl-c1">10</span>))
    <span class="pl-v">Se_data</span>.<span class="pl-en">plot</span>(<span class="pl-s1">kind</span><span class="pl-c1">=</span><span class="pl-s">"barh"</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-v">Se_data</span>.<span class="pl-en">map</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: {<span class="pl-c1">True</span>:<span class="pl-s">"blue"</span>, <span class="pl-c1">False</span>:<span class="pl-s">"red"</span>}[<span class="pl-s1">x</span> <span class="pl-c1">&gt;</span> <span class="pl-c1">0</span>]))</pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/9061708/30394716-c3c381d4-9878-11e7-829a-be3b8c2fea06.png"><img src="https://user-images.githubusercontent.com/9061708/30394716-c3c381d4-9878-11e7-829a-be3b8c2fea06.png" alt="image" style="max-width: 100%;"></a></p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; df = pd.DataFrame({&quot;A&quot;: range(4), &quot;color&quot;: ['red', 'blue', 'blue', 'red']})
&gt;&gt;&gt; ax = df.plot.bar(y='A', color=df['color'])
&gt;&gt;&gt; [p.get_facecolor() for p in ax.patches]
[(1.0, 0.0, 0.0, 1.0),
 (1.0, 0.0, 0.0, 1.0),
 (1.0, 0.0, 0.0, 1.0),
 (1.0, 0.0, 0.0, 1.0)]"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">"A"</span>: <span class="pl-en">range</span>(<span class="pl-c1">4</span>), <span class="pl-s">"color"</span>: [<span class="pl-s">'red'</span>, <span class="pl-s">'blue'</span>, <span class="pl-s">'blue'</span>, <span class="pl-s">'red'</span>]})
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">plot</span>.<span class="pl-en">bar</span>(<span class="pl-s1">y</span><span class="pl-c1">=</span><span class="pl-s">'A'</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s1">df</span>[<span class="pl-s">'color'</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> [<span class="pl-s1">p</span>.<span class="pl-en">get_facecolor</span>() <span class="pl-k">for</span> <span class="pl-s1">p</span> <span class="pl-c1">in</span> <span class="pl-s1">ax</span>.<span class="pl-s1">patches</span>]
[(<span class="pl-c1">1.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">1.0</span>),
 (<span class="pl-c1">1.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">1.0</span>),
 (<span class="pl-c1">1.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">1.0</span>),
 (<span class="pl-c1">1.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">1.0</span>)]</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">It plots correctly but it does not pick the right color per bar. it only pick the color of the first value in the list.<br>
it was working perfectly in pandas 0.19.2</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">the plot should contain a different color as the list is being passed. Similar to matplotlib behavior and the old pandas version</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details> 
<p dir="auto">pandas: 0.20.2<br>
pytest: None<br>
pip: 9.0.1<br>
setuptools: 36.0.1<br>
Cython: None<br>
numpy: 1.12.1<br>
scipy: 0.19.1<br>
xarray: None<br>
IPython: 5.4.1<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: 2.0.2<br>
openpyxl: None<br>
xlrd: 1.0.0<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 0.9999999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: 2.7.1 (dt dec pq3 ext lo64)<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>