I'd like to create an animation where I work with different subplots, each subplot having an animation on its own. I'd like to switch off the axes though, which is why I used plt.axis('off'). Unfortunately, this doesn't work when I add another figure ax2. Now, the axes are only off for ax2, but not for ax. Similary, if I add another figure on top of that, the axes can be seen for both ax and ax2, but not for the third figure. How do I suppress them in every single subplot?
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure()
fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=None, hspace=None)
ax = fig.add_subplot(221, projection='3d')
ax2 = fig.add_subplot(222, projection='3d')
x_array = np.linspace(0, 3, 3)
y_array = np.linspace(0, 3, 3)
X, Y = np.meshgrid(x_array, y_array)
cmap = plt.get_cmap("tab10")
colors = cmap([1, 1, 1, 1, 1, 1, 1, 1, 1])
colors2 = cmap([2, 2, 2, 2, 2, 2, 2, 2, 2])
plt.axis('off')
ax.scatter(X, Y, alpha=1.0, s=50, c=colors, marker='.', linewidth=5)
ax2.scatter(X, Y, alpha=1.0, s=50, c=colors2, marker='.', linewidth=5)
fig.set_size_inches(5, 5)
def update(i, fig, ax):
while i <= 360:
ax.view_init(elev=0.+i, azim=0)
return fig, ax
while i <= 720:
ax2.view_init(elev=0., azim=i)
return fig, ax
anim = FuncAnimation(fig, update, frames=np.arange(0, 720, 2), interval=10, repeat=True, fargs=(fig, ax))
plt.show()