I'm trying to achieve sans-serif axes labels and ticks in matplotlib with pgf. I want to control that by rcParams so I have it working for all subsequent plots. Currently, I'm using
"pgf.rcfonts":False,
"pgf.texsystem": "pdflatex",
"text.usetex": True,
"font.family": "sans-serif",
which I adapted from the mpl docs. It does set all my text in the figure to sans-serif. However, the numbers are kept with a serif font. I want them to be sans-serif. As soon as i force the formatter, its sans-serif. Any way to get it to do that automatically? MinEx follows...
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FormatStrFormatter
#define style
style = {
"pgf.rcfonts":False,
"pgf.texsystem": "pdflatex",
"text.usetex": True,
"font.family": "sans-serif"
}
#set
mpl.rcParams.update(style)
#get data
data = np.random.random(100)
#set up plot
f,ax = plt.subplots()
ax.plot(data)
#label something
ax.set_xlabel('Runner')
The label is sans now. The ticks are not! But when calling
ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
they are.