import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot()
N = 5
ind = np.arange(N)
width = 0.5
vals = []
colors = []
add_c=[(1,0),(4,1),(-1,0),(3,0),(2,1)]
for v in add_c:
vals.append(v[0])
if v[0] == -1:
colors.append('r')
else:
if v[1] == 0:
colors.append('b')
else:
colors.append('g')
ax.bar(ind, vals, width, color=colors,label=[{'r':'red'}])
ax.legend()
ax.axhline(y = 0, color = 'black', linestyle = '-')
plt.show()
Hi Everyone, I was labeling my bar chart and it has three color 'green', 'red' and 'blue' I just want to show on upper right corner of my graph with name plus it color.