python matplotlib legend shows first entry of a list only -
I could not reveal all the legends in matplotlib.
My label array is:
lab = ['Google', 'MSFT', 'APPL', 'Epson', 'WMRT'] / Pre> I used the code given below to legend:
ax.legend (lab, public = "best") < P> Only 'Google' is viewing the top right corner How to show all labels?
Full code:
Imports as imported NP import as PTT from IPIT import import cycle, ISLIC manmans = (80 9 8, 812, 2221, 1000, 562) N = lane (male mines) lab = ['Google', 'MSFT ', APPL' 'epson', 'WMRT'] = = NP range (n) #x width for width = 0.35 # bar width of the bar, ax = plt.subplots () my_colors = list (islas (cycle ['B', 'R', 'G', 'WA E ',' k ']), none, n)) rects1 = ax.bar (ind, mainmen, width, color = my_colors, labels = lab) Ax.set_ylabel (' calculation ') ax.set_title (' trending word ' And their calculation ') ax.legend (lab, public = "best") ax.set_xticks (industrial + width) plt.show () <@fifisegydd Answer by can be useful * Answer this question, simply create different bar charts for legend, and you will get the desired result: Zip, Indian, Maine, Mykolours, X, Y, C, lb Scope: The ax. Bar (x, y, width, color = c, label = lb) ax.legend ()
* Why this presentation may be harmful, to see what the viewer was colorless (or it is printed in black and white ).
Comments
Post a Comment