简体   繁体   English

如何在matplotlib中调整图表?

[英]How to adjust charts in matplotlib?

How to fix this problem? 如何解决这个问题?
Traceback (most recent call last): 追溯(最近一次通话):

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\IPython\core\formatters.py", line 307, in __call__
    return printer(obj)

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\IPython\core\pylabtools.py", line 240, in <lambda>
    png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\IPython\core\pylabtools.py", line 124, in print_figure
    fig.canvas.print_figure(bytes_io, **kw)

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 2252, in print_figure
    **kwargs)

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 545, in print_png
    FigureCanvasAgg.draw(self)

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 459, in draw
    self.renderer = self.get_renderer(cleared=True)

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 476, in get_renderer
    self.renderer = RendererAgg(w, h, self.figure.dpi)

  File "C:\Users\Vrushab PC\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 93, in __init__
    self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)

ValueError: Image size of 8804752x396 pixels is too large. It must be less than 2^16 in each direction.

I think the error code is very clear: the image you are trying to plot is way to big. 我认为错误代码非常清楚:您尝试绘制的图像很大。 You have to reduce the size of the image, ie you have to scale it down. 您必须减小图像的尺寸,即必须缩小图像。 What are you even trying to plot which has a size of 8804752x396 ? 您甚至想绘制大小为8804752x396吗? Are you sure, that you did nothing wrong before? 您确定以前没有做错什么吗? This seems to be very huge. 这似乎非常巨大。

Edit: If you just want to save the image as a png or something like this, you try to change the backend to something else - look here for better suited backends for your task and try them! 编辑:如果您只想将图像另存为png或类似的图片,则尝试将后端更改为其他内容- 在此处查找更适合您任务的后端,然后尝试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM