Python Forum
matplotlib recursion error when repeatedly displaying a surface
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
matplotlib recursion error when repeatedly displaying a surface
#1
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:
Error:
RuntimeError: maximum recursion depth exceeded Traceback (most recent call last): File "C:\Python27\lib\site-packages\matplotlib\cbook\__init__.py", line 387, in process proxy(*args, **kwargs) ... File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 949, in __getitem__ val = dict.__getitem__(self, key) RuntimeError: maximum recursion depth exceeded in cmp
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 ?
Huh
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Error with MatPlotLib subplots Danno 8 3,395 Apr-01-2022, 12:23 AM
Last Post: Danno
  Max recursion depth.... Error MeloB 2 1,868 Feb-16-2022, 05:21 PM
Last Post: MeloB
  Calculating surface area - - OOP or functional? Derek Banas Udemy course Drone4four 5 3,572 Mar-13-2021, 06:22 AM
Last Post: buran
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,205 Mar-11-2021, 10:52 AM
Last Post: buran
  3d Surface where Z is not a function of X and Y richterjan 2 1,712 Nov-11-2020, 04:22 PM
Last Post: michael1789
Bug maximum recursion depth exceeded while calling a Python object error in python3 Prezess 4 3,733 Aug-02-2020, 02:21 PM
Last Post: deanhystad
  Plotting 3D surface plot for non-linear multivariate regression with 5 variables khwajaosama 0 2,699 Jul-02-2020, 04:50 AM
Last Post: khwajaosama
  why this error occured in recursion ashishraikwar 1 1,760 Apr-24-2020, 11:12 AM
Last Post: buran
  Lambda function recursion error DeadlySocks 1 2,043 Apr-13-2020, 05:09 PM
Last Post: deanhystad
  Error message when trying to install Matplotlib in Python3.8 Transitionyte 5 5,169 Jan-22-2020, 11:52 PM
Last Post: Transitionyte

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020