0

Recently I found out that the italic font is not applied to numbers in my legend. Here is the code:

import matplotlib.pyplot as plt

  
    
a = [1,2,3,4,5]
b = [1,3,5,7,9]
c = [1,2,4,6,8]
x = [1,2,3,4,5]
label = ['ABC123',r'it_$\it{ABC123}$', r'bf_$\bf{ABC123}$']
plt.plot(x,a, label = label[0])
plt.plot(x,b, label = label[1])
plt.plot(x,c,label = label[2])
plt.legend()
plt.show()

output figure

As you can see, the number 123 is not italicized, but if I try with bold font, it worked. Is there something I am missing here?

  • 1
    Does this answer your question? [Styling part of label in legend in matplotlib](https://stackoverflow.com/questions/8376335/styling-part-of-label-in-legend-in-matplotlib) – sehan2 Nov 14 '21 at 15:57
  • I also tried latex, but the font for the ticks and legend become inconsistent. There is a method to make them as the same font, but I am still trying to figure out how it works – YHTseng Nov 14 '21 at 16:02

0 Answers0