【问题标题】:How can I change the font size of ticks of axes object in matplotlib [duplicate]如何更改 matplotlib 中轴对象刻度的字体大小 [重复]
【发布时间】:2012-10-19 19:55:21
【问题描述】:

我有一个图,我将子图添加到(插图)。我用过:

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

我现在想更改子图的xtick 字体大小。我尝试了一些幼稚的方法,例如

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

没有任何运气。

那我该怎么做呢?

【问题讨论】:

    标签: python matplotlib axis subplot


    【解决方案1】:
    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()
    

    x/yticks 与matplotlib.text 具有相同的属性

    【讨论】:

    • 这不行!
    • 也不适合我
    • 不适合我。
    【解决方案2】:

    用途:

    subA.tick_params(labelsize=6)
    

    【讨论】:

    • 如果您不想重新指定刻度标签,这是一个更好的解决方案
    猜你喜欢
    • 2012-07-07
    • 1970-01-01
    • 2020-03-29
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    相关资源
    最近更新 更多