Skip to content Skip to sidebar Skip to footer

Scaling Embedded Matplotlib Widget In Qt Application Written In Python Problem

I am writing a simple digital image processing program. To do this I have embedded a mpl widget in my qt application. The user can perform some simple analysis on the image such

Solution 1:

you can use aspect parameter of imshow() to adjust the ratio between the height & weight:

from pylab import *
a = np.zeros((100,10)) # height=100, weight=10
subplot(211)
imshow(a)  # ratio = 10
subplot(212)
imshow(a, aspect=0.1) # ratio = 1
show()

but it will stretch the image.

or you can use xlim(), ylim() the set the range of x-y axis.

imshow(a)
xlim(-50,50)

EDIT:

imshow() will set the aspect property of axe to "equal". you need reset it before calling plot():

self.ui.mplWidget.canvas.ax.set_aspect("auto")
self.ui.mplWidget.canvas.ax.plot(self.xData,self.yData)

Post a Comment for "Scaling Embedded Matplotlib Widget In Qt Application Written In Python Problem"