Reputation: 403
I am fairly new to Python, and I am trying to debug a code that uses both TKinter and MatPlotLib. Initially, I was using Python 2.6.2 with MatPlotLib 1.0.1. I recently updated to Python 2.7 with MatPlotLib 1.4.2... quite a jump, a bumpy one.
Here is the code I have, it is part of a graphic interface in which is shown a graph that is updated based on parameters given by the user:
## -- Algorithm is over, graph the results:
self.graph = Figure()
self.curve = self.graph.add_subplot(111, animated = TRUE, aspect = self.aspectRatio)
self.curve.set_title(translate['my figure'])
self.curve.set_xlabel(translate['xlabel'])
self.curve.set_ylabel(translate['ylabel'])
self.canvas = FigureCanvasTkAgg(self.graph, master = self.leftFrame)
self.canvas.show()
self.canvas.get_tk_widget().pack(pady=15)
self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.leftFrame )
self.toolbar.update()
self.canvas._tkcanvas.pack()
self.inputBox[1][1].focus_set()
After updating to Python 2.7 I basically see nothing in the graphic interface anymore, there is no graph plotted. What surprises me is that there is absolutely no error message.
Thus I am thinking there might have been some modification in the way to actually plot or show a graph from MatPlotLib 1.0.1 to 1.4.2. Is there something obvious that I am missing here ? Could anyone have an idea about what may have changed in MatPlotLib that could create this issue ?
I wish I could be more specific, but the absence of error message makes it extremely hard to debug...
I kept invetigating this issue and found out that the problem appears going from MatPlotLib 1.0.1 to MatPlotLib 1.1.1 which narrows down my scan of the release notes (MatPlotLib, what is new in 1.1) in order to understand what is going on.
Upvotes: 2
Views: 161
Reputation: 6263
The problem is you have "animated" set as true and you are not actually doing an animation (at least not from what you have shown). Change
self.curve = self.graph.add_subplot(111, animated = TRUE, aspect = self.aspectRatio)
to
self.curve = self.graph.add_subplot(111, aspect = self.aspectRatio)
If you want to do an animation here is an example.
Upvotes: 1