Why am I not seeing any red colors for the negative values here?
df = pd.DataFrame([1, -2, 3, -4])
df['positive'] = df[[0]]>0
df[[0]].plot(kind='bar', color=df.positive.map({True: 'g', False: 'r'}))

I am expecting negative values to be red!
As per our discussion below, this is a bug in the latest version of pandas 0.20.2.
This is due to the bug as mentioned by @johnchase.
One workaround till it gets resolved :
print(''.join(df.positive.map({True: 'g', False: 'r'}).values)) # 'grgr'
df[[0]].plot(kind='bar', color=''.join(df.positive.map({True: 'g', False: 'r'}).values))
which outputs

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With