I'm trying to use Matplotlib graphs as part of a camera-ready
submission, and the publishing house requires the use of Type 1 fonts
I'm finding that the PDF backend happily outputs Type-1 fonts for
simple graphs with linear Y axes, but outputs Type-3 fonts for
logarithmic Y axes.
Using a logarithmic yscale incurs the use of mathtext, which seems to
use Type 3 fonts, presumably because of the default use of exponential
notation. I can use an ugly hack to get around this - using
pyplot.yticks() to force the axis ticks to not use exponents - but
this would require moving the plot region to accommodate large labels
(like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they fit.
There's a minimum working example below, which I've tested with the
matplotlib master branch as of today, as well as 1.1.1, which produces
the same behavior, so I don't know that this is a bug, probably just
# Simple program to test for type 1 fonts.
# Generate a line graph w/linear and log Y axes.
from matplotlib import rc, rcParams
# These lines are needed to get type-1 results:
rcParams['ps.useafm'] = True
rcParams['pdf.use14corefonts'] = True
rcParams['text.usetex'] = False
import matplotlib.pyplot as plt
YSCALES = ['linear', 'log']
def plot(filename, yscale):
xvals = range(1, 2)
yvals = xvals
#YTICKS = [1, 10]
#plt.yticks(YTICKS, YTICKS) # locs, labels
ax = plt.gca()
print ",".join([a.get_label() for a in ax.get_yticklabels()])
plt.savefig(filename + '.pdf')
if __name__ == '__main__':
for yscale in YSCALES:
plot('linegraph-' + yscale, yscale)
Does anyone know a clean way to get Type 1 fonts with log axes?