Reputation: 1185
I am trying to change the colors bar in matplotlib for the last colors to be blue. But in the end they are all green.
colors = ['blue' if (i>=19 and i<23) else 'green' for i in
list(range(24))]
df.plot(y='Jan',kind='bar',edgecolor='none',figsize=(16,8),linewidth=2, color=colors)
plt.legend(prop={'size':16})
ax = plt.gca()
plt.gcf().autofmt_xdate()
ax.set_xticklabels(df.index)
plt.tight_layout()
plt.savefig('myimage.svg', format='svg', dpi=1200)
plt.show()
what am I missing? I followed similar tutorials
Here is some data to test the example
sales = [('Jan', [150, 200, 50,150, 200, 50,150, 200, 50, 150, 200, 50,150, 200, 50,150, 200, 50,150, 200, 50,150, 200, 50])]
df = pd.DataFrame.from_items(sales)
Upvotes: 0
Views: 75
Reputation: 1185
df.plot(y='Jan',kind='bar',edgecolor='none',figsize=(16,8),linewidth=2, color=[colors])
it was missing double[[]]
Upvotes: 1