I just installed Python 3.7.1 and ran the following script:
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots(); frame = plt.gca()
x = np.linspace(0,2*np.pi,500)
y = np.sin(x)
ax.set_xticks(np.array([0,np.pi,2*np.pi]))
ax.set_yticks(np.array([-1,0,1]))
frame.set_xticklabels(['$0$', '$\pi$', '$2\pi$'], fontsize=20)
frame.set_yticklabels(['$-1$', '$0$', '$1$'], fontsize=20)
ax.plot(x, y)
plt.tight_layout()
plt.show()
Back in Python 2.7, the x and y tick labels would show up in LaTeX form as I wanted. Now they default to a much less pretty font, and I can't figure out how to show them in LaTeX font. Do I need to install an newer version of matplotlib?
Thanks to tmdavison's link I was able to figure it out. All I need to do is add the following lines of code:
import matplotlib as mpl
mpl.style.use('classic')
Then Matplotlib will default back to the classic style.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.