Drawing a matplotlib widget in QtDesigner

I created this QDialog in QtDesigner:

enter image description here

I would like to know how I can do something in this Matplotlib widget that I posted there. I mean, if I write code to create a matplotlib shape without Qt Designer, I can write something like:

self.figure_canvas = FigureCanvas(Figure())

self.axes = self.figure_canvas.figure.add_subplot(111)

x = np.arange(0,5,0.5)
y = np.sin(x)

and then do:

ax.plot(x,y) or self.axes.plot(x,y)

How can I access this widget to draw something? I hope you help me.

0
source share
1 answer

Based on the screenshot you provided, it seems MatplotlibWidgetto be available both self.matplotlibwidgetfrom your class QMainWindow. This is because of the value specified in the Object column of the Inspector.

, .

self.matplotlibwidget.axes.plot(x, y)
+1

Source: https://habr.com/ru/post/1677045/


All Articles