change text in legend matplotlib

Solutions on MaxInterview for change text in legend matplotlib by the best coders in the world

showing results for - "change text in legend matplotlib"
Joris
29 Mar 2020
1plt.plot(range(10), label='Some very long label')
2plt.plot(range(1,11), label='Short label')
3L=plt.legend()
4L.get_texts()[0].set_text('make it short')
5plt.savefig('temp.png')