• <noscript id="e0iig"><kbd id="e0iig"></kbd></noscript>
  • <td id="e0iig"></td>
  • <option id="e0iig"></option>
  • <noscript id="e0iig"><source id="e0iig"></source></noscript>
  • matplotlib animation 動畫 使用

    import numpy as np
    import matplotlib.pyplot as plt 
    from matplotlib.animation import FuncAnimation
    
    fig, ax = plt.subplots()
    xdata,ydata = [],[]
    ln, = ax.plot([],[],'r-',animated=False)
    
    def init():
        ax.set_xlim(0,2*np.pi)
        ax.set_ylim(-1,1)
        return ln, 
    
    def update(frame):
        xdata.append(frame)
        ydata.append(np.sin(frame))
        ln.set_data(xdata,ydata)
        return ln, 
    
    ani = FuncAnimation(fig,update,frames=np.linspace(0,2*np.pi,128),init_func=init, blit=True)
    plt.show()
    

    import numpy as np
    import matplotlib.pyplot as plt 
    from matplotlib import animation
    
    fig,ax = plt.subplots()
    x = np.linspace(0,2*np.pi,200)
    y = np.sin(x)
    l = ax.plot(x,y)
    dot, = ax.plot([],[],'ro')
    
    def init():
        ax.set_xlim(0,2*np.pi)
        ax.set_ylim(-1,1)
        return 1
    
    def gen_dot():
        for i in np.linspace(0,2*np.pi,200):
            newdot = [i,np.sin(i)]
            yield newdot
    
    def update_dot(newd):
        dot.set_data(newd[0],newd[1])
        return dot,
    
    ani = animation.FuncAnimation(fig,update_dot,frames=gen_dot,interval=100,init_func=init)
    ani.save('animation2.gif',writer='imagemagic',fps=30)
    plt.show()

     

     

    版權聲明:本文為DarrenXf原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
    本文鏈接:https://blog.csdn.net/DarrenXf/article/details/82428590

    智能推薦

    Ubuntu matplotlib animation save 保存 使用 例子

    animation_demo.py     frame_grabbing_sgskip.py 可以生成MP4文件。然而MP4文件傳不上來,我們把它保存成gif   animated_histogram.py    bayes_update.py     double_pendulum_sgskip.py dynamic_imag...

    Android 屬性動畫(Property Animation) 使用詳解

    謹以文章記錄學習歷程,如有錯誤還請指明。 動畫綜述 Google大大對動畫的總述如下: Animations can add visual cues that notify users about what’s going on in your app. They are especially useful when the UI changes state, such as when...

    Android 視圖動畫(View Animation) 使用詳解

    謹以文章記錄學習歷程,如有錯誤還請指明。 動畫綜述 Google大大對動畫的總述如下: Animations can add visual cues that notify users about what’s going on in your app. They are especially useful when the UI changes state, such as when...

    幀動的使用animation(動畫)

    幀東的使用: 1.幀動的意思是在一個操作中可以讓畫面可以移動多個幀.讓畫面實現多動畫效果 幀動,讓一個圖片移動到另一個位置.這叫一幀,然后在移動到另外一個位置,那么一共就移動了兩幀. 要想讓圖片實現幀動效果用transform:translate(100px);和transition:transfom 1s ease;再配合hover等等事件就可以實現, 具體代碼: 代碼效果: 原來的位置 移動后...

    廣告輪播動畫(animation的使用)

    這里寫目錄標題 效果展示 代碼 HTML CSS 效果展示 代碼 HTML CSS...

    猜你喜歡

    3D游戲編程與設計——游戲對象與圖形基礎章節作業與練習

    3D游戲編程與設計——游戲對象與圖形基礎章節作業與練習 3D游戲編程與設計——游戲對象與圖形基礎章節作業與練習 自學資源 作業內容 1、基本操作演練【建議做】 天空盒的制作: 地圖的制作: 整體效果: 2、編程實踐 項目要求: 項目結構: 代碼詳解: Actions: ISSActionCallback.cs SSAction.cs SSAction...

    FlycoTabLayout 的使用

    FlycoTabLayout 一個Android TabLayout庫,目前有3個TabLayout SlidingTabLayout:參照PagerSlidingTabStrip進行大量修改. 新增部分屬性 新增支持多種Indicator顯示器 新增支持未讀消息顯示 新增方法for懶癌患者 CommonTabLayout:不同于SlidingTabLayout對ViewPager依賴,它是一個不...

    爬蟲項目實戰八:爬取天氣情況

    爬取天氣情況 目標 項目準備 接口分析 代碼實現 效果顯示 寫入本地 目標 根據天氣接口,爬取接下來一周的天氣情況。 項目準備 軟件:Pycharm 第三方庫:requests,BeautifulSoup,csv 接口地址:http://api.k780.com:88/?app=weather.future&weaid=城市名&appkey=10003&sign=b59bc...

    關于web項目的目錄問題

    先給段代碼: 上面這個代碼一直出錯,我不知道原因,后面不停的查找資料發現了問題:我的web項目輸出目錄有問題,因為我也是第一次用idea寫web項目,發現很多bug 其實都沒有太大問題,我們需要注意的是你必須在out這個輸出文件夾中擁有這個文件,out輸出文件夾會默認過濾這些文件...

    二叉搜索樹轉化為雙向鏈表

    題目描述: 輸入一棵二叉搜索樹,將該二叉搜索樹轉換成一個排序的循環雙向鏈表。要求不能創建任何新的節點,只能調整樹中節點指針的指向。 為了讓您更好地理解問題,以下面的二叉搜索樹為例: 我們希望將這個二叉搜索樹轉化為雙向循環鏈表。鏈表中的每個節點都有一個前驅和后繼指針。對于雙向循環鏈表,第一個節點的前驅是最后一個節點,最后一個節點的后繼是第一個節點。 下圖展示了上面的二叉搜索樹轉化成的鏈表。&ldqu...

    精品国产乱码久久久久久蜜桃不卡