pandas ipython笔记本中的熊猫子图标题大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35582531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 00:44:47  来源:igfitidea点击:

pandas subplot title size in ipython notebook

pythonpandasmatplotlib

提问by I am not George

I plotted two plots side by side in an ipython notebook cell. But, I am having trouble changing the size of the title. I can change the size of the labels by adding the argument fontsize = 20. How do I change the title for dfand df2.

我在 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])

回答by tmdavison

You can change the size of an existing title on the Axes using title.set_size()

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

axes[0].title.set_size(40)

回答by Brad Miller

Try breaking out the title property onto its own, something like this should work:

尝试将 title 属性分解为自己的属性,这样的事情应该可以工作:

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

and remove title from the plot commands, not sure why it's not working in line, but in a quick test it doesn't work inline for me either.

并从绘图命令中删除标题,不知道为什么它不能在线工作,但在快速测试中它对我来说也不能在线工作。