matplotlib recursion error when repeatedly displaying a surface - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: matplotlib recursion error when repeatedly displaying a surface (/thread-21222.html) |
matplotlib recursion error when repeatedly displaying a surface - AdeIsHere - Sep-19-2019 When I scroll through my data on a matplotlib 3d surface I get a recursion eror although there is no explicit place where recursion is used. my code to display the surface (z data stored in zlines array) is: import matplotlib.pyplot as plt ... fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ... def display_plot(currentFrameNumber): Z = zlines[currentFrameNumber] ax.clear() ax.set_zlim(0.0, 400.0) ax.plot_surface(X, Y, Z, cmap="magma") plt.show()I scroll through the zlines using a button: from matplotlib.widgets import Button ... class Index(object): def next(self, event): self.__frameNumber += 1 display_plot(self.__frameNumber ) ... callback = Index() axnext = plt.axes([0.81, 0.05, 0.09, 0.075]) bnext = Button(axnext, '>') bnext.on_clicked(callback.next)When I press the next button the display correctly shows the next zlines frame. If I do this about 43 times then I get the recursion error: it is something to do with plt.show() because if i remove that call then although it isn't displayed correctly I get no recursion error.I'm sort of new to python and matplotlib so maybe someone more experienced can more clearly see the error ? |