python - 如何在 Matplotlib 中折叠饼图上方和轴标题下方的空间?
问题描述
出于某种原因,我在一对饼图和它们的标题之间得到了很大的空间。我不确定是什么控制了这个间距。
我想折叠这个空间。至少,我们可以把馅饼放在空间的中心吗?
这是一些类似于我实际在做的示例代码:
import matplotlib.pyplot as plt
x = ['a', 'b', 'c']
y = [1.1, 3.5, 2.2]
y1_sizes = y
y2_sizes = y
fig, axarr = plt.subplots(1, 2)
ax1 = axarr[0]
ax2 = axarr[1]
ax1.pie(y1_sizes, shadow=True, startangle=90, autopct='%1.1f%%')
ax1.axis('equal')
ax1.set_title('Old Stuff')
ax2.pie(y2_sizes, shadow=True, startangle=90, autopct='%1.1f%%')
ax2.axis('equal')
ax2.set_title('New Stuff')
lgd1 = ax1.legend(x, loc='lower center')
lgd2 = ax2.legend(x, loc='lower center')
fig.suptitle('My Chart Title', fontweight='bold')
这是结果
解决方案
推荐阅读
- c# - 使用 JSON 将数据输出从数据库渲染到 Highcharts
- java - Spring Boot Batch:需要将 JobExecutionContext 放入 ItemWriteListener
- javascript - Django - 数据未提交到我的数据库,但没有错误
- angular - Angular Reactive Forms - 自定义验证中的 .disable() 导致“超出最大调用堆栈大小”
- javascript - 如何从角度的开始月份禁用或只读日期选择器月份?
- python - 如何在 numpy 数组中插入经过轻微修改的序列?
- javascript - 从 google api 函数返回 lat 和 lng
- swift - 我们可以使用 Cocoa Swift 在 Mac 上挂载/卸载设备/磁盘/usb 吗?
- react-hooks - 使用带有 React DND 的句柄
- asp.net-core - asp.net 核心身份在使用 cookie 和 jwt 身份验证方案时避免重复声明