【问题标题】:Change Font Size of Single Tick Matplotlib Python更改 Single Tick Matplotlib Python 的字体大小
【发布时间】:2020-07-18 22:27:41
【问题描述】:

我有一个图表,其中 x 刻度标签是相当大的字符串。我能够将字体大小设置为不碍眼的好大小,但是其中一个标签的字符串比其他任何标签都长得多。我不想更改所有刻度的字体大小,因为它很难阅读。我只想改变一个勾号。根据我绘制的数据,这个刻度并不总是在图表上的同一位置(刻度并不总是相同的顺序,它是一个条形图),但刻度的名称总是Underneath Screen,如果是对任何示例都有帮助。

【问题讨论】:

    标签: python matplotlib plot graph seaborn


    【解决方案1】:

    这样就可以了

    import matplotlib.pyplot as plt
    x = [1,2,3]
    y = [2,4.5,4]
    plt.plot(x,y)
    plt.xticks([1,2,3], ['this', 'is', 'custom'])
    
    font_sizes = [10,20,30]
    
    for tick, size in zip(plt.xticks()[-1], font_sizes):
        tick.set_fontsize(size)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-20
      • 1970-01-01
      • 2011-04-23
      • 2021-10-30
      • 1970-01-01
      • 2017-03-04
      • 2018-12-20
      相关资源
      最近更新 更多