Repository navigation
Closed
Labels
Milestone
Description
In testing #6540, I can see that neither Cairo backend is able to render images correctly.
With GTKCairo:
Traceback (most recent call last):
File ".../lib/matplotlib/backends/backend_gtk.py", line 438, in expose_event
self._render_figure(self._pixmap, w, h)
File ".../lib/matplotlib/backends/backend_gtk.py", line 426, in _render_figure
self.figure.draw (self._renderer)
File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File ".../lib/matplotlib/figure.py", line 1129, in draw
renderer, self, dsu, self.suppressComposite)
File ".../lib/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File ".../lib/matplotlib/axes/_base.py", line 2353, in draw
mimage._draw_list_compositing_images(renderer, self, dsu)
File ".../lib/matplotlib/image.py", line 163, in _draw_list_compositing_images
flush_images()
File ".../lib/matplotlib/image.py", line 147, in flush_images
image_group[0].draw(renderer)
File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File ".../lib/matplotlib/image.py", line 464, in draw
renderer.draw_image(gc, l, b, im)
File ".../lib/matplotlib/backends/backend_cairo.py", line 180, in draw_image
im.shape[1]*4)
TypeError: expected a writeable buffer objectWith GTK3Cairo:
Traceback (most recent call last):
File ".../lib/matplotlib/backends/backend_gtk3cairo.py", line 45, in on_draw_event
self._render_figure(w, h)
File ".../lib/matplotlib/backends/backend_gtk3cairo.py", line 34, in _render_figure
self.figure.draw (self._renderer)
File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File ".../lib/matplotlib/figure.py", line 1129, in draw
renderer, self, dsu, self.suppressComposite)
File ".../lib/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File ".../lib/matplotlib/axes/_base.py", line 2353, in draw
mimage._draw_list_compositing_images(renderer, self, dsu)
File ".../lib/matplotlib/image.py", line 163, in _draw_list_compositing_images
flush_images()
File ".../lib/matplotlib/image.py", line 147, in flush_images
image_group[0].draw(renderer)
File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File ".../lib/matplotlib/image.py", line 464, in draw
renderer.draw_image(gc, l, b, im)
File ".../lib/matplotlib/backends/backend_cairo.py", line 180, in draw_image
im.shape[1]*4)
TypeError: expected a writeable buffer object
Activity
QuLogic commentedon Jun 8, 2016
Bisect on the original branch points to one of c9cae50, 3b7d1bb, 4a05302, 0aa222a, cf11aea, 0793aa2; perhaps that's narrow enough to figure it out.
cc @mdboom
jenshnielsen commentedon Jun 14, 2016
Interestingly enough this seems to be a python2 issue only. I can reproduce the error on python 2.7 but not on 3.5
The following reproduces the error without matplotlib
jenshnielsen commentedon Jun 14, 2016
So a in cairocffi this is fundamentally because
ctypes.c_char.from_buffer_copy(memoryview(data))doesn't work. Regardless of the type of data. Numpy array, bytesarray ...
jenshnielsen commentedon Jun 14, 2016
This stackoverflow question is an example of the same issue http://stackoverflow.com/questions/28984692/ctypes-from-buffer-with-memoryviews-in-python-2-7-and-python-3-4
WIP solution to matplotlib#6562
QuLogic commentedon Jun 22, 2016
Fixed by #6602.