matplotlib savefig错误,bbox_英寸=&x27;紧密的';和光栅化

matplotlib savefig错误,bbox_英寸=&x27;紧密的';和光栅化,matplotlib,Matplotlib,当我运行光栅化示例并将bbox\u inches='tight'参数添加到任何savefig()函数时,我得到以下错误。还有其他人有这个问题吗?我找不到错误报告。Im使用matplotlib 1.4.0和python 2.7.6 Traceback (most recent call last): File "raster.py", line 45, in <module> plt.savefig("test_rasterization.pdf", dpi=150,bbo

当我运行光栅化示例并将
bbox\u inches='tight'
参数添加到任何
savefig()
函数时,我得到以下错误。还有其他人有这个问题吗?我找不到错误报告。Im使用matplotlib 1.4.0和python 2.7.6

Traceback (most recent call last):
  File "raster.py", line 45, in <module>
    plt.savefig("test_rasterization.pdf", dpi=150,bbox_inches='tight')
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 576, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 1470, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 2192, in print_figure
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 2469, in print_pdf
    self.figure.draw(renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 1079, in draw
    func(*args)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 2092, in draw
    a.draw(renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 58, in draw_wrapper
    before(artist, renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 43, in before
    renderer.start_rasterizing()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_mixed.py", line 96, in start_rasterizing
    self._bbox_inches_restore)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/tight_bbox.py", line 86, in process_figure_for_rasterizing
    r = adjust_bbox(figure, bbox_inches, fixed_dpi)
NameError: global name 'figure' is not defined
回溯(最近一次呼叫最后一次):
文件“raster.py”,第45行,在
plt.savefig(“test_rasterization.pdf”,dpi=150,bbox_inches='tight')
savefig中的文件“/usr/local/lib/python2.7/dist packages/matplotlib/pyplot.py”,第576行
res=图savefig(*args,**kwargs)
savefig中的文件“/usr/local/lib/python2.7/dist packages/matplotlib/figure.py”,第1470行
self.canvas.print_图(*args,**kwargs)
文件“/usr/local/lib/python2.7/dist packages/matplotlib/backend_base.py”,第2192行,如图所示
**kwargs)
文件“/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py”,第2469行,以print_pdf格式
self.figure.draw(渲染器)
文件“/usr/local/lib/python2.7/dist packages/matplotlib/artist.py”,第59行,在draw_包装中
绘制(艺术家、渲染器、*args、**kwargs)
文件“/usr/local/lib/python2.7/dist packages/matplotlib/figure.py”,第1079行,在绘图中
func(*args)
文件“/usr/local/lib/python2.7/dist packages/matplotlib/artist.py”,第59行,在draw_包装中
绘制(艺术家、渲染器、*args、**kwargs)
文件“/usr/local/lib/python2.7/dist packages/matplotlib/axes/_base.py”,绘图中的第2092行
a、 绘制(渲染器)
文件“/usr/local/lib/python2.7/dist packages/matplotlib/artist.py”,第58行,在draw_包装中
之前(艺术家、渲染器)
文件“/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py”,前面第43行
renderer.start_光栅化()
文件“/usr/local/lib/python2.7/dist packages/matplotlib/backends/backend\u mixed.py”,第96行,在开始光栅化中
自身。_bbox_inches_restore)
文件“/usr/local/lib/python2.7/dist-packages/matplotlib/tight\u bbox.py”,第86行,正在进行光栅化
r=调整bbox(图,bbox英寸,固定dpi)
NameError:未定义全局名称“figure”
这是一个已知的bug(),已被修复()


如果可以编辑安装,则需要删除三个字符。您还可以下载相关代码更改的差异(),这些更改可以与修补程序一起应用。

使用python 2.7.8和matplotlib 1.3.1,它对我来说很好