Sorry for the late reply, but I was skiing for a week…
For your example to do something useful, you need at least to call plt.show()
:
fig, ax = plt.subplots()
plt.show()
But anyway, you’re creating a wx.Frame
and then using matplotlib’s plt
interface to create another toplevel window. These two are not related anyhow.
You probably want to embed a matplotlib canvas into a wx.Frame
. For this, the plt
interface is not too useful.
The matplotlib documentation has some examples on embedding.
For more comprehensive examples, you may look at the ones included with wxGlade:
https://github.com/wxGlade/wxGlade/tree/master/examples/matplotlib
https://github.com/wxGlade/wxGlade/tree/master/examples/matplotlib2
https://github.com/wxGlade/wxGlade/tree/master/examples/matplotlib3
The first one is very basic. The third demonstrates most of the building blocks that you’ll need when embedding a canvas and handling matplotlib events.
Embedding typcially looks like this:
import matplotlib
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
figure = self.matplotlib_figure = Figure()
# 1x1 grid, first subplot
self.matplotlib_axes = figure.add_subplot(111)
self.matplotlib_canvas = FigureCanvas(parent, wx.ID_ANY, figure)
where parent is e.g. a wx.Frame
or better a wx.Panel
having sizers that will manage the layout.
Regards,
Dietmar