[Matplotlib-users] Migrating some code which use NavigationToolbar2QT to matplotlib 2.x AND 3.x

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Feb 15 03:44:02 EST 2019


I have this code in one of  the project I neded to update.
Since we are targetting Debian buster, I need to support
matplotlib 2.X (python2) AND matplotlib 3.X  (python3)

class HiddenToolbar(NavigationToolbar2QT):
    def __init__(self, corner_callback, canvas):
        super(HiddenToolbar, self).__init__(canvas, None)
        self._corner_callback = corner_callback

    def press(self, event):
        self._corner_preclick = self._views()

    def release(self, event):
        if self._corner_preclick == self._views():
            self._corner_callback(event.xdata, event.ydata)
        self._corner_preclick = None

The problem, I have is with the  _views() method.
The 3.X version, complains that it is not available in the NavigationToolbar2QT.

so I would like to know how to rewrite this in order to be 2.X and 3.X compatible.
I tryed to find some information in the documentation about this but I did not find it.

thanks for your help.


More information about the Matplotlib-users mailing list