I could not get all the legends to appear in matplotlib.
My Labels array is:
lab = ['Google', 'MSFT', 'APPL', 'EXXON', 'WMRT']
I use the below code to add the legend:
ax.legend(lab,loc="best")
Am seeing only 'Google' in top right corner. How to show all labels?
Full code:
import numpy as np
import matplotlib.pyplot as plt
from itertools import cycle, islice
menMeans = (8092, 812, 2221, 1000, 562)
N = len(menMeans)
lab = ['Google', 'MSFT', 'APPL', 'EXXON', 'WMRT']
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, N))
rects1 = ax.bar(ind, menMeans, width, color=my_colors,label=lab)
# add some
ax.set_ylabel('Count')
ax.set_title('Trending words and their counts')
ax.set_xticks(ind+width)
ax.legend(lab,loc="best")
plt.show()