【问题标题】:pandas subplot title size in ipython notebookipython笔记本中的熊猫子图标题大小
【发布时间】:2016-06-05 14:01:56
【问题描述】:

我在 ipython 笔记本单元格中并排绘制了两个图。但是,我无法更改标题的大小。我可以通过添加参数fontsize = 20 来更改标签的大小。如何更改 dfdf2 的标题。

fig, axes = plt.subplots(ncols=2, figsize = (20,10))
df.plot('barh', title = 'Legal Collectible Answer Distribution', fontsize = 20, ax = axes[0])
df2.plot(kind = 'pie', autopct = '%1.0f%%', legend = False, title = 'Legal Collectible Answer Distribution', fontsize = 20, ax =axes[1])

【问题讨论】:

    标签: python pandas matplotlib


    【解决方案1】:

    尝试单独拆分 title 属性,这样应该可以:

    df.plot.title('Legal Collectible Answer Distribution', fontsize=20)
    df2.plot.title('Legal Collectible Answer Distribution', fontsize=20)
    

    并从绘图命令中删除标题,不知道为什么它不能正常工作,但在快速测试中它也不能内联工作。

    【讨论】:

    • pandas.DataFrame.plot上没有title属性,不知道以前有没有,现在没有了。
    【解决方案2】:

    您可以使用 title.set_size() 更改轴上现有标题的大小

    axes[0].title.set_size(40)
    

    【讨论】:

      猜你喜欢
      • 2015-04-07
      • 2013-02-07
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 2016-03-23
      • 2016-10-14
      • 2018-11-03
      • 2015-02-13
      相关资源
      最近更新 更多