matplotlib sets the font properties of the 3D plot tick marks

2D plot ticks

It is relatively simple for matplotlib to set the font properties of the 2D plot tick marks.

  • use plt:
plt.xticks(fontproperties='Times New Roman', size=12)
plt.yticks(fontproperties='Times New Roman', size=12)
  • Use ax:
    Refer to the 3D method

3D plot ticks

Because pltthere is no zticks, it can only be used 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

reference:

Guess you like

Origin blog.csdn.net/lyh458/article/details/127185218