Matplotlib-动态更新图表
生活随笔
收集整理的這篇文章主要介紹了
Matplotlib-动态更新图表
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這里以散點圖的動態更新為例
import matplotlib.pyplot as plt import numpy as np import randomplt.ion() # 開啟交互模式 plt.subplots()for j in range(20):plt.clf() # 清空畫布plt.xlim(0, 10) # 因為清空了畫布,所以要重新設置坐標軸的范圍plt.ylim(0, 10)x = [random.randint(1,9) for i in range(10)]y = [random.randint(1,9) for i in range(10)]plt.scatter(x, y)plt.pause(0.2)plt.ioff() plt.show()總結
以上是生活随笔為你收集整理的Matplotlib-动态更新图表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Matplotlib-barh-绘制水平
- 下一篇: matplotlib-plot-绘制折线