【问题标题】:Remove axis from animation.ArtistAnimation python从动画中删除轴。ArtistAnimation python
【发布时间】:2021-06-06 02:30:06
【问题描述】:

这是我在 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()

【问题讨论】:

    标签: python matplotlib animation imshow


    【解决方案1】:
        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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      • 2011-09-29
      相关资源
      最近更新 更多