如何制作动画二维散点图?

时间:2018-09-16 23:19:34

标签: python animation matplotlib scatter-plot

我想知道是否有人可以帮助我弄清楚如何为该2D散点图设置动画。我已经尝试了几件事,但最终得到了一堆空白。我要做的就是取每个切片,然后换成新的切片,这样看来我正在遍历整个情节。我将非常感谢您的帮助!谢谢!

from matplotlib import pyplot as plt

#from matplotlib.animation import animation

import numpy as np

plt.figure(figsize=(13,13))

x=[]

y=[]

z=[]


filename=(r"minnimill6-feldman fix.txt")

f1=open(filename)

fin = open(filename,'r')

survey = np.loadtxt(fin)

   x = survey[:,14]

   y = survey[:,15]

   z = survey[:,16]


# set min and max       

print(np.min(z),np.max(z),np.size(z))

minz = np.min(z)-0.01

maxz = np.min(z) + (((np.max(z)+4.01) - 
np.min(z))/10)
print(minz,maxz)

#Get the indesies          
qind0 = np.array(np.where((z > minz) & (z < maxz)))

plt.plot(x[qind0],y[qind0],'b.')


# set min and max       
#The max because it is the new min moving up the z 
minz = maxz - 4.01

maxz = minz + ((np.max(z) - np.min(z))/10)

print(minz,maxz)

#Get the indesies         

qind0 = np.array(np.where((z > minz) & (z < maxz)))

plt.plot(x[qind0],y[qind0],'r.')


count = 0
while True:
    print(count)
    count += 1

    # set min and max       
    minz = maxz - 4.01

    maxz = minz + (((np.max(z)+4.01) - np.min(z))/10)

    print(minz,maxz)

    #Get the indesies         

    qind0 = np.array(np.where((z > minz) & (z < maxz)))

    plt.plot(x[qind0],y[qind0],'r.')


    if count >= 32:
        break

0 个答案:

没有答案