Bold and italic label of axis

How to write this x in xlabel bold and italic?

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties    

params = {'text.usetex' : True,
          'font.size' : 14,
          '' : 'lmodern',
          'text.latex.unicode': True,

fig, ax = plt.subplots()

    ax.annotate('x', xy=(0.93, -0.01), ha='left', va='top', xycoords='axes fraction', weight='bold', style='italic')

Adding of from matplotlib import rc does not help.


Using normal text

Use weight and style arguments:

ax.annotate("x", ..., weight='bold', style='italic')

Using Latex

i.e. when rcParams["usetex"] = True,

ax.annotate(r'\textbf{\textit{x}}', ...)

as seen e.g. in correct-way-to-bold-italicize-text

Posted on by ImportanceOfBeingErnest

Relevant tags