从 animation.ArtistAnimation python 中删除轴
Remove axis from animation.ArtistAnimation python
这是我在 python 中创建的动画的屏幕截图:
我想删除正在创建的第二个轴。这是我的代码:
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.animation as animation
import matplotlib.image as mpimg
%matplotlib notebook
steps = np.arange(0,t_steps,5)
img = []
for k in steps:
img.append(mpimg.imread(r'C:\Users\nikos.000\MHD1D\figures\jpg\test\_test%d.jpg'% k) ) #path file
frames = [] # for storing the generated images
fig = plt.figure()
for i in range(len(img)):
frames.append([plt.imshow(img[i], cmap=cm.Greys_r,animated=True, aspect='auto')])
ani = animation.ArtistAnimation(fig, frames, interval=50, blit=True,
repeat_delay=1000)
# ani.save('movie.mp4')
plt.show()
fig = plt.figure("Animation")
ax = fig.add_subplot(111)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
#append logic to ims
ani = animation.ArtistAnimation(fig, ims)
这应该可以完成任务。
如果您也想删除边界框。使用:
ax.axis('off')
这是我在 python 中创建的动画的屏幕截图:
我想删除正在创建的第二个轴。这是我的代码:
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.animation as animation
import matplotlib.image as mpimg
%matplotlib notebook
steps = np.arange(0,t_steps,5)
img = []
for k in steps:
img.append(mpimg.imread(r'C:\Users\nikos.000\MHD1D\figures\jpg\test\_test%d.jpg'% k) ) #path file
frames = [] # for storing the generated images
fig = plt.figure()
for i in range(len(img)):
frames.append([plt.imshow(img[i], cmap=cm.Greys_r,animated=True, aspect='auto')])
ani = animation.ArtistAnimation(fig, frames, interval=50, blit=True,
repeat_delay=1000)
# ani.save('movie.mp4')
plt.show()
fig = plt.figure("Animation")
ax = fig.add_subplot(111)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
#append logic to ims
ani = animation.ArtistAnimation(fig, ims)
这应该可以完成任务。
如果您也想删除边界框。使用:
ax.axis('off')