I've spent a lot of time trying to find a way to embed matplotlib histograms within a PyQt5 widget and I can't find anything on how to do this. There's a lot of information on how to put figures into PQ5, but following those steps with histograms hasn't worked for me.
The data I'm passing to plt.hist() is a list (not an nparray, just a list). I know the plot is being made because if I call plt.show() I get the histogram in a separate window. I've tried passing plt.hist() (and its individual elements since it returns a tuple) to a Figure and FigureCanvassTQAgg but that hasn't worked. I've tried mixing and matching lines of code from tons of different tutorials but nothing has worked so far.
I feel like I'm missing something simple. Here's the code for the widget:
class HistogramWindow(FigureCanvas):
def __init__(self, data):
super().__init__()
plt.hist(data, bins = 10)
and the widget that calls it:
self.histogram = HistogramWindow(self.score_stats)
self.layout().addWidget(self.histogram)
Like I said this successfully builds the histogram, I just need to know how to embed it in the widget.