What I'm trying to do is control the fontsize of individual entries in a legend in pyplot. That is, I want the first entry to be one size, and the second entry to be another. This was my attempt at a solution, which does not work.
import numpy as np
import matplotlib.pyplot as pltx = np.arange(1,5,0.5)
plt.figure(1)
plt.plot(x,x,label='Curve 1')
plt.plot(x,2*x,label='Curve 2')
leg = plt.legend(loc = 0, fontsize = 'small')
leg.get_texts()[0].set_fontsize('medium')
plt.show()
My expectation is that the default size for all legend entries would 'small'. I then get a list of the Text objects, and change the fontsize for only a single Text object to medium. However, for some reason this changes all Text object fontsizes to medium, rather than just the single one I actually changed. I find this odd since I can individually set other properties such as text color in this manner.
Ultimately, I just need some way to change an individual entry's fontsize for a legend.