Reputation: 11
I want to render my plots with setting the rcParameter 'text.usetex = True' and save it to a pdf.
If i set 'text.usetex = False' and set the font to 'Times New Roman' --> only TimesNewRomanPS-ItalicMT and TimesNewRomanPSMT are embedded (see usetex_false).
But if i set 'text.usetex = True' --> instead of Times only cm-fonts (eg CMMI12, CMR10,...) are embedded (see usetex_true).
How to can I use 'text.usetex = True' and embed Times New Roman fonts instead of cm-fonts?
My Code:
"""
Demo of a line plot on a polar axis.
"""
import numpy as np
import matplotlib.pyplot as plt
with plt.rc_context({'text.usetex' : False, #---> no Times New Roman embedded when set to true, instead cm-fonts
'font.family' : 'serif',
'font.serif': 'Times New Roman',
'mathtext.fontset' : 'custom',
'mathtext.cal' : 'serif:cursive',
'mathtext.rm' : 'serif',
'mathtext.tt' : 'monospace',
'mathtext.it' : 'serif:italic',
'mathtext.bf' : 'serif:bold',
'mathtext.sf' : 'sans'}):
r = np.arange(0, 3.0, 0.01)
theta = 2 * np.pi * r
r = r*1000000000
ax = plt.subplot(111, projection='polar')
ax.plot(theta, r, color='b', linewidth=3)
ax.grid(True)
plt.title(r'Some text with latex in it $10_4 \times \theta = \Phi$')
plt.savefig(r'Test_text_embedded_of.pdf', papertype='None')
Upvotes: 0
Views: 318
Reputation: 11
For me adding following lines helped:
from matplotlib.backends.backend_pgf import FigureCanvasPgf
import matplotlib as mpl
mpl.backend_bases.register_backend('pdf', FigureCanvasPgf)
Upvotes: 0