Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python gtkcairo后端的matplotlib功能有限_Python_Matplotlib_Gtk - Fatal编程技术网

Python gtkcairo后端的matplotlib功能有限

Python gtkcairo后端的matplotlib功能有限,python,matplotlib,gtk,Python,Matplotlib,Gtk,我正在开发一个应用程序,它将matplotlib嵌入到python和gtk2程序中,并使用matplotlib的gtkcairo后端。我成功地使用了axis.plot,但是如果我尝试使用类似scatter()的东西来制作颜色贴图,或者使用像lasso这样的交互式工具,我会得到一个错误。出现错误时,会在问题详细信息中报告: Most Recent Project: C:\Users\Documents\p\p.aprojx Platform: AMD64 Traceback (most rece

我正在开发一个应用程序,它将matplotlib嵌入到python和gtk2程序中,并使用matplotlib的gtkcairo后端。我成功地使用了axis.plot,但是如果我尝试使用类似scatter()的东西来制作颜色贴图,或者使用像lasso这样的交互式工具,我会得到一个错误。出现错误时,会在问题详细信息中报告:

Most Recent Project: C:\Users\Documents\p\p.aprojx 
Platform: AMD64
Traceback (most recent call last):
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\backends\backend_gtk.py", line 435, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\backends\backend_gtk.py", line 423, in _render_figure
    self.figure.draw (self._renderer)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\figure.py", line 1034, in draw
    func(*args)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\axes.py", line 2086, in draw
    a.draw(renderer)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Work\components\win64\lib\python2.7\matplotlib\collections.py", line 717, in draw
    for x in self._sizes]
TypeError: Not implemented for this type
我想知道问题是什么,如果有什么我可以做的。目前,我认为gtkcairo是问题所在,或者使用gtk2而不是3,但我不确定目前更改这两种情况是否可行

下面是工作正常的代码,但是如果我将plot()更改为scatter()或其他任何内容,就会出现错误

def plot(self, x, y, xlabel, ylabel, semilogX = False, semilogY = False, plot_circles = False):
    self._figure.clear()
    axes = matplotlib.axes.Subplot(self._figure, 111)
    self._figure.add_axes(axes)

    if semilogX:
        axes.set_xscale('log')
    if semilogY:
        axes.set_yscale('log')
    if plot_circles:
        self.pts = axes.plot(x, y, 'o', c='blue', alpha=0.4)
    else:
        self.pts = axes.plot(x, y, ',', c='blue')
    axes.set_xlabel(xlabel)

    # the extra space is a hack for what appears to be a bug in the GTK backend where it draws
    # the y label horizontally, then rotates it to be vertical, but it does not figure out the
    # extent of the text correctly so leaves the trailing edge of a character (e.g. the leg of
    # an 'h' behind) - the ' ' means the left behind object is not very visible...sigh
    axes.set_ylabel(ylabel + ' ')
    configure_axes(axes, True)
    self.canvas.show()

请发布您的代码,没有它我们无法帮助。x和y输入的类型是什么?它们是numpy数组、列表还是其他什么?另外,如果您使用
axes=self.\u图。添加子图(111)
而不是手动构造,会发生什么情况?您可以发布独立代码吗?尝试删除alpha,我知道PS不支持alpha混合,也不确定cairo。