I need to know how to plot a graph using matplotlib in the main interface. I am using PyQt5. I was able to plot a simple graph on another window. When I use pycharm it shows the chart in a separate window. But I need to plot it on my main interface. Also I am trying to develop an app for rasberi pi, so I need to know how to plot the graph according to the data from serial read. Help me to fix. Thank you.
class ApplicationWindow(QtWidgets.QMainWindow):
def __init__(self):
super(ApplicationWindow, self).__init__()
self.ui = Ui_Form()
self.ui.setupUi(self)
self.ui.pushButtonGraph.clicked.connect(self.load_Data)
def load_Data(self):
x = [2, 4, 6, 8, 10]
y = [6, 7, 8, 2, 10, ]
plt.bar(x, y, label='Bar 1')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Graph test')
plt.legend()
plt.show()