throwaway17434
throwaway17434

Reputation: 831

Updating Matplotlib 3D with new data and ticker values

When I use axes.cla() on my 3D.plot to remove all the lines, modify the axis' and then call draw() on that figure again, the axis labels and lines become thicker. And it is only on the axis that are modified with ticker. My guess is i have to delete the old axis labels somehow, how can I do that?

Here is a minimal example code of what I am talking about. I linked the redraw to mouse click on the canvas. Code is ment for Python 3. (I already tried a workaround with clf() and redraw the whole figure, but in 3D mode it does not work.)

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.ticker as ticker

def onclick(event):
    event.inaxes.cla()
    event.inaxes.w_xaxis.set_major_locator(ticker.LinearLocator())
    event.inaxes.w_xaxis.set_major_locator(ticker.LinearLocator())
    event.canvas.draw()


fig = plt.figure()
axes = fig.add_subplot(111, projection='3d')

fig.canvas.mpl_connect('button_press_event', onclick)

plt.show()

Upvotes: 0

Views: 193

Answers (1)

throwaway17434
throwaway17434

Reputation: 831

I got a workaround by not using cla(). I only removed my plot data in axes.lines and axes.collections.

Upvotes: 0

Related Questions