python plt图片保存最大化,将Matplotlib图形保存为全屏图像

在使用Pandas和Matplotlib创建图表工具时,发现默认保存的图像显示不清晰,图例和标签互相遮挡。扩大窗口到全屏可以解决此问题,但直接保存图像时又会恢复到默认状态。如何将全屏显示的Matplotlib图像保存为.png文件?文中提供了针对不同matplotlib后端的三种最大化窗口的方法,以实现保存全屏图像。
摘要由CSDN通过智能技术生成

I'm building a small graphing utility using Pandas and MatPlotLib to parse data and output graphs from a machine at work.

When I output the graph using

plt.show()

I end up with an unclear image that has legends and labels crowding each other out like so.

7c41f05d598999e0b67e4cee030ef194.png

However, expanding the window to full-screen resolves my problem, repositioning everything in a way that allows the graph to be visible.

I then save the graph to a .png like so

plt.savefig('sampleFileName.png')

But when it saves to the image, the full-screen, correct version of the plot isn't saved, but instead the faulty default version.

How can I save the full-screen plt.show() of the plot to .png?

I hope

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值