Recently I used matplotlib with wx to plot some histograms, this solution maybe can help you to solve your problem. The code is inherited from a panel, and you need to add this component like a panel. To set the data use the function SetData.
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
class HistogramPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.figure = Figure(figsize=(-1, -1))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axis = self.figure.add_subplot(111)
self.rootSizer = wx.BoxSizer(wx.VERTICAL)
self.rootSizer.Add(self.canvas, 1, wx.EXPAND | wx.GROW)
self.SetSizer(self.rootSizer)
self.FitInside()
self.Layout()
def SetData(self, values, color="black", linewidth=1):
self.axis.clear()
self.axis.plot(values, color=color, linewidth=linewidth)
self.axis.set_xlim([0, 256])
self.Layout()