matplotlib设置3D plot刻度线的字体属性

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

参考:

猜你喜欢

转载自blog.csdn.net/lyh458/article/details/127185218
今日推荐