I have a 3D matplotlib graph. When I zoom in, or change the bounds of the graph, points on the graph will still display even when they are outside of the bounds.
Is there anyway for the data in the graph to not display when it is no longer in bound?
I've seen solutions where you can mask the data before plotting so that it doesn't show if it goes out of bounds. But that's not what I want, I need the data to automatically hide if it gets out of bounds or to reappear if it gets back in the frame.
Here's an example graph.
import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = plt.axes(projection ='3d') z = np.linspace(0, 1, 100) x = z * np.sin(25 * z) y = z * np.cos(25 * z) ax.plot3D(x, y, z, 'green') plt.show()