SpanSelector with gtk3cairo backend

SpanSelector is a powerful widget that allows to define a particular
region in a Figure. Some time ago I switched to python3 and needed to
use gtk3cairo instead of gtkagg; to my knowledge there is still a
message preventing using agg backend with python3. Unfortunately since
then I am not able to use SpanSelector widget with gtk3cairo. For
instance with the example [1], an error message appears:
  File "/usr/lib/python3/dist-packages/matplotlib/widgets.py", line
1197, in update_background
    self.background = self.canvas.copy_from_bbox(self.ax.bbox)
AttributeError: 'FigureCanvasGTK3Cairo' object has no attribute
'copy_from_bbox'
This using version 1.4.2 of matplotlib.

Does exists a way to have SpanSelector operating with gtk3cairo
backend ? I tried to look down to the code of gtkagg but it refers to
the C implementation of the library (_RendererAgg), is there an
equivalent in Cairo ?

Arnaud.

[1] http://matplotlib.org/examples/widgets/span_selector.html

Not sure what you mean about agg + py3k, it should work fine (as we test it).

The issue is that the cairo backend is a vector backend, which does not have a notion of blitting, which is something that span selector uses to make it nice and snappy. Should be able to get it to work by passing the kwarg useblit=False to the constructor.

Tom

There was an issue with the GTK3Agg backend on Python 3 due to a missing feature in the python 3 port of PyCairo but this has been fixed in Matplotlib 1.4.0 by making it possible to use cairocffi as an alternative to
PyCairo. CairoCFFI implements the missing feature. (While the Agg backends doesn’t use Cairo to render the figures it still needs python binding for Cairo AFAIK)

/Jens

···

On Mon, Nov 10, 2014 at 11:26 PM, Thomas Caswell <tcaswell@…149…> wrote:

Not sure what you mean about agg + py3k, it should work fine (as we test it).

The issue is that the cairo backend is a vector backend, which does not have a notion of blitting, which is something that span selector uses to make it nice and snappy. Should be able to get it to work by passing the kwarg useblit=False to the constructor.

Tom


Comprehensive Server Monitoring with Site24x7.

Monitor 10 servers for $9/Month.

Get alerted through email, SMS, voice calls or mobile push notifications.

Take corrective actions from your mobile device.

http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

There was an issue with the GTK3Agg backend on Python 3 due to a
missing feature in the python 3 port of PyCairo but this has been
fixed in Matplotlib 1.4.0 by making it possible to use cairocffi as an
alternative to PyCairo.

This is exactly the issue I meant.

(...)

(...)

        The issue is that the cairo backend is a vector backend, which
        does not have a notion of blitting, which is something that
        span selector uses to make it nice and snappy. Should be able
        to get it to work by passing the kwarg `useblit=False` to the
        constructor.
        
        Tom

In fact I stupidly copied the example [1], missing completely this
argument in the constructor. Setting useblit=False makes it working
nicely. Thanks.

Arnaud.

[1] http://matplotlib.org/examples/widgets/span_selector.html

PS: For the records, here is the full message that appears when setting
useblit=True in [1] and matplotlibrc contains "backend : GTK3Cairo",
matplotlib version 1.4.2 (debian):

$ ./testspan.py
Traceback (most recent call last):
  File
"/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3cairo.py", line 45, in on_draw_event
    self._render_figure(w, h)
  File
"/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3cairo.py", line 34, in _render_figure
    self.figure.draw (self._renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 59,
in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1085,
in draw
    self.canvas.draw_event(renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py",
line 1778, in draw_event
    self.callbacks.process(s, event)
  File "/usr/lib/python3/dist-packages/matplotlib/cbook.py", line 540,
in process
    proxy(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/cbook.py", line 415,
in __call__
    return mtd(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/widgets.py", line
1197, in update_background
    self.background = self.canvas.copy_from_bbox(self.ax.bbox)
AttributeError: 'FigureCanvasGTK3Cairo' object has no attribute
'copy_from_bbox'

···

Le mardi 11 novembre 2014 à 08:56 +0000, Jens Nielsen a écrit :

On Mon, Nov 10, 2014 at 11:26 PM, Thomas Caswell <tcaswell@...149...> > wrote:

I should point out that the animation module tries to determine if the canvas can blit if the user sets it to True. If it can’t blit, then it simply ignores the True setting. Maybe we should do something similar like here as well?

···

On Tue, Nov 11, 2014 at 4:50 PM, Arnaud Gardelein <arnaud@…1044…> wrote:

Le mardi 11 novembre 2014 à 08:56 +0000, Jens Nielsen a écrit :

There was an issue with the GTK3Agg backend on Python 3 due to a

missing feature in the python 3 port of PyCairo but this has been

fixed in Matplotlib 1.4.0 by making it possible to use cairocffi as an

alternative to PyCairo.

This is exactly the issue I meant.

(…)

On Mon, Nov 10, 2014 at 11:26 PM, Thomas Caswell <tcaswell@…149…>

wrote:

(…)

    The issue is that the cairo backend is a vector backend, which
    does not have a notion of blitting, which is something that
    span selector uses to make it nice and snappy.  Should be able
    to get it to work by passing the kwarg `useblit=False` to the
    constructor.
    Tom

In fact I stupidly copied the example [1], missing completely this

argument in the constructor. Setting useblit=False makes it working

nicely. Thanks.

Arnaud.

[1] http://matplotlib.org/examples/widgets/span_selector.html

PS: For the records, here is the full message that appears when setting

useblit=True in [1] and matplotlibrc contains “backend : GTK3Cairo”,

matplotlib version 1.4.2 (debian):

$ ./testspan.py

Traceback (most recent call last):

File

“/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3cairo.py”, line 45, in on_draw_event

self._render_figure(w, h)

File

“/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3cairo.py”, line 34, in _render_figure

self.figure.draw (self._renderer)

File “/usr/lib/python3/dist-packages/matplotlib/artist.py”, line 59,

in draw_wrapper

draw(artist, renderer, *args, **kwargs)

File “/usr/lib/python3/dist-packages/matplotlib/figure.py”, line 1085,

in draw

self.canvas.draw_event(renderer)

File “/usr/lib/python3/dist-packages/matplotlib/backend_bases.py”,

line 1778, in draw_event

self.callbacks.process(s, event)

File “/usr/lib/python3/dist-packages/matplotlib/cbook.py”, line 540,

in process

proxy(*args, **kwargs)

File “/usr/lib/python3/dist-packages/matplotlib/cbook.py”, line 415,

in call

return mtd(*args, **kwargs)

File “/usr/lib/python3/dist-packages/matplotlib/widgets.py”, line

1197, in update_background

self.background = self.canvas.copy_from_bbox(self.ax.bbox)

AttributeError: ‘FigureCanvasGTK3Cairo’ object has no attribute

‘copy_from_bbox’


Comprehensive Server Monitoring with Site24x7.

Monitor 10 servers for $9/Month.

Get alerted through email, SMS, voice calls or mobile push notifications.

Take corrective actions from your mobile device.

http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel