How can I change the font size of ticks of axes object in matplotlib [duplicate]

拟墨画扇 提交于 2019-12-03 10:50:23

问题


I have a figure I added subfigure to (inset). I have used:

fig = plt.figure()
ax = fig.add_subplot(111)
subA = fig.add_axes([0.4,0.14,0.2,0.2])

I now want to change the xtick font size of the subfigure. I tried some naive approach such as

subA.get_xaxis().get_xticks().set_fontsize(10)

without any luck.

How can I do this then?


回答1:


Use:

subA.tick_params(labelsize=6)



回答2:


fig = plt.figure()
ax = fig.add_subplot(111)
plt.xticks([0.4,0.14,0.2,0.2], fontsize = 50) # work on current fig
plt.show()

the x/yticks has the same properties as matplotlib.text



来源:https://stackoverflow.com/questions/13139630/how-can-i-change-the-font-size-of-ticks-of-axes-object-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!