Umkehren der Reihenfolge der Legende

Ich verwende den folgenden code, um eine Darstellung der Balken. Präsentieren müssen, eine Legende in umgekehrter Reihenfolge. Wie kann ich es tun?

colorsArr = plt.cm.BuPu(np.linspace(0, 0.5, len(C2)))
p = numpy.empty(len(C2), dtype=object)
plt.figure(figsize=(11,11))

prevBar = 0
for index in range(len(C2)):
    plt.bar(ind, C2[index], width, bottom=prevBar, color=colorsArr[index], 
            label=C0[index])
    prevBar = prevBar + C2[index]

# positions of the x-axis ticks (center of the bars as bar labels)
tick_pos = [i+(width/2) for i in ind]

plt.ylabel('Home Category')
plt.title('Affinity - Retail Details(Home category)')
# set the x ticks with names
plt.xticks(tick_pos, C1)
plt.yticks(np.arange(0,70000,3000))
plt.legend(title="Line", loc='upper left' )
# Set a buffer around the edge
plt.xlim(-width*2, width*2)
plt.show()
InformationsquelleAutor Yakov | 2016-01-03
Schreibe einen Kommentar