Why Are Colors Not Working In Matplotlib For This Example?
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({Tru
Solution 1:
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
Post a Comment for "Why Are Colors Not Working In Matplotlib For This Example?"