zoukankan      html  css  js  c++  java
  • matplotlib三维绘制动态曲线

    api里面的例子比较复杂,本人自己写了一个例子绘制一条三维动态曲线

     1 #外部获得数据
     2 myCurve = np.fromfile('data.bin', dtype=np.float).reshape(-1,3)
     3 xLength,j = myCurve.shape
     4 fig = plt.figure()
     5 ax1=plt.axes(projection='3d')
     6 #初始化绘制
     7 line, = ax1.plot([],[],[],animated=True)
     8 #定义动画函数
     9 def animate(i):
    10     line.set_xdata(myCurve[:i+1,0])
    11     line.set_ydata(myCurve[:i+1,1])
    12     line.set_3d_properties(myCurve[:i+1,3])
    13     # 这个,很关键,不然无法迭代
    14     return line,
    15 ani = animation.FuncAnimation(fig,animate,xLength,interal=5, repeat=False, bit=True)
    16 plt.show()
  • 相关阅读:
    Linq&Lumbda
    PS颜色模式
    WPF绑定方式
    明三杰刘健
    齐有鲍叔,郑有子皮
    朱厚照
    管子&小白
    时间
    人外有人之神箭手养繇基篇
    楚共王
  • 原文地址:https://www.cnblogs.com/m-zhang-yang/p/15541491.html
Copyright © 2011-2022 走看看