我正在尝试从我创建的绘图中删除空白,请参见下面的照片:
可以看到,右边和底部都有一个大白点,怎么解决?,请按我的脚本执行:
fig = plt.figure(figsize=(7,7))
ax1 = plt.subplot2grid((4,3), (0,0),)
ax2 = plt.subplot2grid((4,3), (1,0),)
ax3 = plt.subplot2grid((4,3), (0,1),)
ax4 = plt.subplot2grid((4,3), (1,1),)
data = self.dframe[i]
tes = print_data(data, self.issues, self.color, self.type_user)
tes.print_top(data=data, top=10, ax=ax1, typegraph="hbar", problem=self.issues[i], tone=self.color[i])
tes.print_top(data=data, top=10, ax=ax2, typegraph="prod_bar", problem=self.issues[i], tone=self.color[i])
tes.print_top(data=data, top=10, ax=ax3, typegraph="reg_hbar", problem=self.issues[i], tone=self.color[i])
tes.print_top(data=data, top=10, ax=ax4, typegraph=self.type_user, problem=self.issues[i], tone=self.color[i])
problem = self.issues[i]
plt.tight_layout()
name = problem + str('.PNG')
plt.close(fig)
fig.savefig(name)
任何帮助都将不胜感激
你可以用
plt.subplots_adjust(left=0.09, bottom=0.07, right=0.98, top=0.97, wspace=0.2 , hspace=0.17 )
调整窗口。 但问题是你的情节里有很多地方是空的 也许你该换衣服plt.subplot2grid((4,3)
。。。到plt.subplot2grid((2,2)
你创建的子块太多了!
如果我们看这一行:
我们可以看到给subblot2grid的第一个参数是要生成的子块网格的维度,在本例中是4行3列。然后在图左上角的子图中绘制(给出第二个参数),这会留下很多未使用的空间。
所以要解决这个问题,可以使用以下方法减少子块的数量:
完整示例:
给予:
相关问题 更多 >
编程相关推荐