2D plot ticks
matplotlib设置2D plot刻度线的字体属性还是比较简单的。
- 使用
plt
:
plt.xticks(fontproperties='Times New Roman', size=12)
plt.yticks(fontproperties='Times New Roman', size=12)
- 使用
ax
:
参考3D的方法
3D plot ticks
因为plt
没有zticks
,所以只能用ax
了。
from matplotlib import font_manager
ticks_font = font_manager.FontProperties(family='Times New Roman')
for tick in ax.get_xticklabels():
tick.set_fontproperties(ticks_font)
for tick in ax.get_yticklabels():
tick.set_fontproperties(ticks_font)
for tick in ax.get_zticklabels():
tick.set_fontproperties(ticks_font)
ax.tick_params(labelsize=12) # font size for all axis
参考: