Skip to content

Fix image plotting in Cairo backends - #6602

Merged
tacaswell merged 2 commits into
matplotlib:v2.xfrom
jenshnielsen:cairoimage
Jun 20, 2016
Merged

tacaswell merged 2 commits into
matplotlib:v2.xfrom
jenshnielsen:cairoimage

Conversation

@jenshnielsen

@jenshnielsen jenshnielsen commented Jun 18, 2016 •

Copy link
Copy Markdown
Member

WIP solution to #6562

Call cairo.ImageSurface.create_for_data with an array that both py2cairo and cairocffi knows how to get a pointer too and size of.

This seems to correctly resolve the issue for the Cairo backend but not the GTK(3)Cairo backends.

Current status

  • Python2.7, Cairo backend, cairocffi
  • Python2.7, Cairo backend, py2cairo
  • Python3.5, Cairo backend, cairocffi
  • Python2.7, GTKCairo backend, cairocffi
  • Python2.7, GTKCairo backend, py2cairo
  • Python2.7, GTK3Cairo backend, cairocffi
  • Python2.7, GTK3Cairo backend, py2cairo
  • Python3.5, GTK3Cairo backend, cairocffi
  • Python3.5, Cairo backend, py3cairo non functional with latests release of py3cairo
  • Python3.5, GTKCairo backend, cairocffi python 3 NOT Supported by GTK2
  • Python3.5, GTKCairo backend, py3cairo python 3 NOT Supported by GTK2
  • Python3.5, GTK3Cairo backend, py3cairo non functional with latests release of py3cairo

Call cairo.ImageSurface.create_for_data with an array that both py2cairo and cairocffi knows how to get a pointer too and size of
@jenshnielsen

Copy link
Copy Markdown
Member Author

More testing. Cairocffi works correctly with GTK3 if py2/3cairo is installed but not otherwise. This is probably just a concequense of the fact that gtk/pygobject is build against py2/3cairo so it can't function without.

The gtk2 backend however breaks if Cairocffi is installed

@jenshnielsen

Copy link
Copy Markdown
Member Author

The issue with cairocffi and GKT2 is not new and can be reproduced on 1.5.x

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 438, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 426, in _render_figure
    self.figure.draw (self._renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py", line 62, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1159, in draw
    func(*args)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py", line 62, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2319, in draw
    a.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py", line 62, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/image.py", line 394, in draw
    renderer.draw_image(gc, l, b, im)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_cairo.py", line 181, in draw_image
    ctx.set_source_surface (surface, x, y)
TypeError: must be cairo.Surface, not ImageSurface

@tacaswell tacaswell closed this Jun 18, 2016
@tacaswell tacaswell reopened this Jun 18, 2016
@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Jun 20, 2016
@tacaswell
tacaswell merged commit 003dea9 into matplotlib:v2.x Jun 20, 2016
@jenshnielsen
jenshnielsen deleted the cairoimage branch June 21, 2016 06:36
@QuLogic

QuLogic commented Jun 22, 2016

Copy link
Copy Markdown
Member

Can I close #6562 then?

@tacaswell

Copy link
Copy Markdown
Member

@QuLogic Can you do the 2.x into master merge?

@QuLogic

QuLogic commented Jun 22, 2016

Copy link
Copy Markdown
Member

Neither commit message indicates it should be closed, so that did nothing. But I ask because there are some items unchecked here...

@tacaswell

Copy link
Copy Markdown
Member

oh, yes, close this. We decided that those platforms are not a) already broken on 1.5 and b) old c) otherwise non-functional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants