I was asked to change some figures in my paper from using Type 3 Font to using Type 1 Font, and I found the instruction to do just the job.
By adding the following 3 lines, I am able to generate a Type 1 Font .pdf file:
matplotlib.rcParams['ps.useafm'] = True
matplotlib.rcParams['pdf.use14corefonts'] = True
matplotlib.rcParams['text.usetex'] = True
However, while the font of x-tick and y-tick on my old plot were uniform, their fonts somehow became different after I added the 3 lines of code. This seems strange to me since the change is applied to only one of the ticks.
Here is the script in python:
import matplotlib
matplotlib.use('PDF')
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
# Switch to Type 1 Fonts.
matplotlib.rcParams['ps.useafm'] = True
matplotlib.rcParams['pdf.use14corefonts'] = True
matplotlib.rcParams['text.usetex'] = True
def plot_pdf_figure(path, title, xl, yl, xt_list, yl_list, style_list):
fig = plt.figure(path)
ax = fig.add_subplot(111)
ax.set_title(title)
ax.set_xlabel(xl, style='italic')
ax.set_ylabel(yl)
x_list = range(0, len(xt_list))
plt.xticks(x_list, xt_list)
for y_list, style in zip(yl_list, style_list):
ax.plot(x_list, y_list, style)
pp = PdfPages(path)
pp.savefig(fig)
pp.close()
plot_pdf_figure("test_plot.pdf", "test", "x-axis", "y-axis", [1,2,3,4,5,6], [[1,2,4,8,16,32],[32,16,8,4,2,1]], ["-ro","-gs"])
Thank you for any guidance or help!
