![]() The function that gets called when changing the slider will then only need to update the viewing angle and redraw the canvas. In order to be able to later update the figure the %matplotlib notebook backend is needed. The idea is of course to draw a single figure. Or in other words: If in each call to the function, a new figure is created, is it surprising that you will end up with a lot of figures? What you call overhead is the source of the problem. (further I realize that there is overhead in recreating the figure and axes but that is the lesser part of my current concerns.)Īx = fig.add_subplot(111, projection='3d')Īngle1_slider = widgets.IntSlider(20, min = 0, max = 60)Īngle1_label = widgets.Label(value = 'Angle 1 value is: ' + str(angle1_slider.value))Īngle1_label.value = 'Angle 1 value is: ' + str(value.new)Īngle1_slider.observe(update_angle1, names = 'value') I tried plt.close(fig), plt.cla() and plt.clf() without success. The problem is that a new figure is added below the previous one, instead of the current figure cleared. ![]() The test code below shows what I am trying to achieve. For that reason I integrated a slider from ipywidgets to update the view angle. I want a 3D scatter plot in MatPlotLib to be rotated interactively in a Jupyter Python notebook.
0 Comments
Leave a Reply. |