You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I'm struggeling when exporting figures to pdf using usetex=True:
When i run the following Code:
"""
Demo of a line plot on a polar axis.
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pgf import FigureCanvasPgf
import matplotlib as mpl
mpl.backend_bases.register_backend('pdf', FigureCanvasPgf)
from matplotlib.ticker import OldScalarFormatter, ScalarFormatter
with plt.rc_context({'text.usetex' : True,
'font.family' : 'Times New Roman',
'font.serif': 'Times New Roman', # --> no error when using 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',
'text.latex.unicode' : True,
'pgf.rcfonts' : True}):
r = np.arange(0, 3.0, 0.01)
theta = 2 * np.pi * r
r = r*1000000
#ax = plt.subplot(111, projection='polar')
ax = plt.subplot(111)
ax.plot(theta, r, color='b', linewidth=3)
ax.yaxis.major.formatter._useMathText = True
ax.xaxis.major.formatter._useMathText = True
ax.grid(True)
print(ax.get_xaxis().get_major_formatter())
#ax.xaxis.set_major_formatter(OldScalarFormatter())
#ax.yaxis.set_major_formatter(OldScalarFormatter())
#plt.title(r'Some text with latex in it $10_4 \times \theta = \Phi$')
plt.savefig(r'Test_text_embedded_on.pdf', papertype='None')
plt.show()
In the generated pdf Test_text_embedded_on.pdf the desired Times New Roman Font is not embedded, only the default CMR12-font is embedded.
I found out that it has something to do with the ScalarFormatter --> if I uncomment ax.xaxis.set_major_formatter(OldScalarFormatter()) and ax.yaxis.set_major_formatter(OldScalarFormatter()) the ticks changed (not desired) but in this case the TimesNewRoman font is embedded.
Is there a way to fix this to get TimesNewRoman in the Ticks?
My Setup:
Python 3.5
Matplotlib 1.5.1 --> installed with anaconda
Windows 10
The text was updated successfully, but these errors were encountered:
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Hello!
I'm struggeling when exporting figures to pdf using usetex=True:
When i run the following Code:
In the generated pdf Test_text_embedded_on.pdf the desired Times New Roman Font is not embedded, only the default CMR12-font is embedded.
I found out that it has something to do with the ScalarFormatter --> if I uncomment
ax.xaxis.set_major_formatter(OldScalarFormatter())
andax.yaxis.set_major_formatter(OldScalarFormatter())
the ticks changed (not desired) but in this case the TimesNewRoman font is embedded.Is there a way to fix this to get TimesNewRoman in the Ticks?
My Setup:
Python 3.5
Matplotlib 1.5.1 --> installed with anaconda
Windows 10
The text was updated successfully, but these errors were encountered: