You may be able to use the following pattern on the Text
objects contained in the legend() :
leg = plt.legend()
for i, text in enumerate(leg.get_texts()):
# pretend the element to be changed is in index position 3
if i == 3:
text.set_weight("bold")
text.set_size("x-large")
# or equivalently with one call to setp()
plt.setp(text, weight="bold", size="x-large")
EDIT:
Looks like changing things in one text object inside a legend actually applies to all objects. One workaround that works is to use mathtext like so text.set_text(r'$\mathbf{label}$')
. In the loop, we'd need to retrieve the label and deal with mathtext "condensing" the spaces. Here's an example:
line1, = plt.plot([3,2,1], marker='o', label='Line 1 label is long and has spaces')
line2, = plt.plot([1,2,3], marker='o', label='Line 2')
leg = plt.legend()
for i, text in enumerate(leg.get_texts()):
# the element to be changed is in index position 0
if i == 0:
t = text.get_text()
new_label = "".join([i + r"\/" for i in t.split()])
text.set_text(r'$\mathbf{}$'.format("{" + new_label + "}"))
I don't know if using mathtext or latex is acceptable to you, but it appears to allow unique formatting of a single legend text label.