Using character font for Greek characters in TeX via matplotlib

To annotate my numbers in Greek letters in the matplotlib Python package, I use the following:

import matplotlib
matplotlib.use('PDF')
import matplotlib.pyplot as plt
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['ps.useafm'] = True
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['pdf.fonttype'] = 42
# plot figure
# ...
# annotate figure
plt.xlabel(r'$\mu$ = 50')
plt.ylabel(r'$\sigma$ = 1.5')

This makes the character equal and everything to the right of it in the Helvetica font, as expected, and Greek characters by default have the regular TeX font (which, I think, Times New Roman.)

How can I make the font used for Greek letters instead be the font "Symbol"? It’s important for me not to appear in the default TeX font for Times.

thank you for your help.

+3
source share
1 answer

, ; . , TeX, TeX .

Helvetica , Symbol. Unicode, :

plt.xlabel(u'\u03bc = 50')
plt.ylabel(u'\u03c3 = 1.5')

/ Unicode Unicode .

, matplotlib Unicode. , , matplotlib.

( Symbol: , , , . , .)

+9

Source: https://habr.com/ru/post/1730074/


All Articles