'How do I change my legend labels to other words?

enter image description here

I have tried several different ways, but I have had no luck so far. I am trying to change my bar chart legend labels from (0,1,2,3,4,5,6) to (Monday, Tuesday, Wednesday Thursday, Friday, Saturday). Help please!



Solution 1:[1]

Try:

legend_labels = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

plt.legend(labels = legend_labels, title = 'Weekdays', loc = 'upper left')
plt.show()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Itzik Shamli