How can I change the font of matplotlib tick labels? I'd like to change it to Computer Modern 10 (called "cm" in matplotlib I believe), however, I don't want to render it in TeX. I've tried numerous ways of doing this, but none of them seem to work.
Asked
Active
Viewed 297 times
1 Answers
-3
func = lambda x, pos: "" if np.isclose(x,0) else x
plt.gca().xaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(func))
plt.gca().yaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(func))
Works in my case!

Axel Persinger
- 331
- 2
- 14
-
1This is just [the answer to a previous question](https://stackoverflow.com/a/44661312/4124317) and has nothing to do with changing the font. – ImportanceOfBeingErnest Jun 21 '17 at 08:49