Change main plot legend label text
Another way:
ax.legend(labels=mylabels)
You need to gain access of the legend()
object and use set_text()
to change the text values, a simple example:
plt.plot(range(10), label='Some very long label')
plt.plot(range(1,11), label='Short label')
L=plt.legend()
L.get_texts()[0].set_text('make it short')
plt.savefig('temp.png')
In your case, you are changing the first item in the legend, I am quite sure the 0
index in L.get_texts()[0]
applies to your problem too.