I'm having difficulties using Matplotlibs Basemap in combination with a PyQt4 interface. Basically I create a Pyqt4 Canvas in which I plot a Matplotlib Basemap and some markers. I call the function in

self.button3 = QtGui.QPushButton('plot', self) 
self.button3.clicked.connect(lambda: self.plot(geom0))

And pass a geometry to my plot(geom0) function.

def plot(self, geom0):
                x1, y1 = zip(*((geom0.GetX(i), geom0.GetY(i)) for i in range(geom0.GetPointCount())))
                print geom0

                self.m = Basemap(projection='merc', resolution = None, area_thresh = 0.1,llcrnrlon=6.66321, llcrnrlat=50.48198, urcrnrlon=7.54761, urcrnrlat=51.46085)

                x,y = self.m(x1, y1)
                self.m.plot(x, y, 'D-', markersize=4, linewidth=2, color='k', markerfacecolor='b')


This works fine and the canvas is filled and a map without any kind of resolution is shown with my Linestring from geom0 but when I change the resolution to low 'l' or high 'h' Python quits unexpectedly. Changing the resolution to low or high takes a while to calculate and I guess that is where the problem lies.

Do you have any ideas how I can tell PyQt to wait until the Basemap is calculated?

1 Answer 1


Do not use lambda function for triggering.

Read this: https://eli.thegreenplace.net/2011/04/25/passing-extra-arguments-to-pyqt-slot/

  • In the article you link, the author says to use lambda....
    – YoLecomte
    Nov 23, 2018 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.