Reputation: 103
How to write this x in xlabel bold and italic?
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.rcParams['text.latex.preamble']=[r"\usepackage{lmodern}"]
params = {'text.usetex' : True,
'font.size' : 14,
'font.family' : 'lmodern',
'text.latex.unicode': True,
}
plt.rcParams.update(params)
fig, ax = plt.subplots()
ax.annotate('x', xy=(0.93, -0.01), ha='left', va='top', xycoords='axes fraction', weight='bold', style='italic')
plt.show()
Adding of from matplotlib import rc
does not help.
Upvotes: 1
Views: 4344
Reputation: 339220
Use weight
and style
arguments:
ax.annotate("x", ..., weight='bold', style='italic')
i.e. when rcParams["usetex"] = True
,
ax.annotate(r'\textbf{\textit{x}}', ...)
as seen e.g. in correct-way-to-bold-italicize-text
Upvotes: 4