My goal is to have multiple relatively small graphs being generated in the same wxPython panel. Additionally, I would like to manually resize the graphs and place them where I want. This causes issues because my graphs are displayed incorrectly. Changing the size of the graph does not change the graph itself, it only cuts off parts of the graph. It's easier to see what I mean if you run my code. As you can see, the graph on the right is fully displayed, but it is too big and I want to make it a bit smaller. However, the smaller graph on the left is missing half of the graph! Does anyone have an idea as to how this can be fixed?
import wx
import matplotlib as mpl
mpl.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
class MainFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, None, size=(1200,900))
self.panel_1 = Panel_one(self)
class Panel_one(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
self.temp_graph = Graph(self, position=(50, 100), size=(400,400))
self.temp_graph = Graph(self, position=(550, 100), size=(700, 700))
class Graph(wx.Panel):
def __init__(self, parent, position, size):
wx.Panel.__init__(self, parent, pos=position, size=size)
self.figure = Figure(None)
self.canvas = Canvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
if __name__ == "__main__":
app = wx.App(redirect=False)
frame = MainFrame(None)
frame.Show()
app.MainLoop()
I have found another thread with a similar problem, but the thread's solution did not work correctly and the graphs were still displayed incorrectly.