Сравните две строки NSStrings

import csv
import sys
import getopt
import socket
import time
import numpy as np
import matplotlib
from scipy.misc import imread
from matplotlib import pyplot as plt
import warnings
fig, ax = plt.subplots()
ax.set_xlim(-158, 553)
ax.set_ylim(-290, 733)
im = plt.imread("")
plt.imshow(img, zorder=0, extent=[0.5, 8.0, 1.0, 7.0])

fig.show()
l_global=[]
points=[]
master_tag_csvlink='c:/logfolde.log.csv'
csvfile=open(master_tag_csvlink, 'r')
for ainfo in csvfile:
        line= ainfo
        l_list= list(line.split('_'))
        l_local=[]
        for i in range(int(l_list[0])):
            l_local.append(list(l_list[i+1].split(',')))
        function1= lambda x,i: x[i] # return list[n,X] of elements at x
        c= lambda x,l: [x for i in range(l) if True]
        for i in range(len(l_local)):
            l_local[i][1],l_local[i][2]=int(l_local[i][1]),int(l_local[i][2])

        if l_global: #In begining l_glocal is empty, so just copy the data in to l_global
            l_global=l_local[:]
            for i in range(len(l_global)):
                points.append(plt.plot(function1(l_global[i],1),function1(l_global[i],2),'g',label="Tag:%s, X:%f, y: %f"%(function1(l_global[i],0),function1(l_global[i],1),function1(l_global[i],2))))



        else: # compare the l_local & l_global for any updates 
            tag_Id=map(function1,l_local,c(0,len(l_local))) #list of list of tagId,x,y TagId is filtered - local
            mTag_Id=map(fuction1,l_global,c(0,len(l_global))) #list of list of tagId,x,y TagId is filtered - master

            for i in mTag_Id: 
                if i not in tag_Id: #comparing master tags and tag_Id's
                    index=mTag_Id.index(i) ###############  Tags in master list but not in Tag_id
                    copy_point=l_global[index]
                    [removing_point]=points[index]########  means tag is in-active ,turn tag color into red
                    removing_point.remove()
                    del points[index]

                    points.insert(index,plt.plot(function1(l_global[index],1),function1(l_global[index],2),'r',label="Tag:%s, X:%f, y: %f"%(function1(l_global[i],0),function1(l_global[i],1),function1(l_global[i],2))))

                elif i in tag_Id: # append the tag into l_global
                    index=mTag_Id.index(i) ###############  Tags in master list but not in Tag_id
                    l_global[index]=l_local[index][:]
                    [removing_point]=points[index]########  means tag is active update coordinates
                    removing_point.remove()
                    del points[index]
                    points.insert(index,plt.plot(function1(l_global[index],1),function1(l_global[index],2),'g',label="Tag:%s, X:%f, y: %f"%(function1(l_global[i],0),function1(l_global[i],1),function1(l_global[i],2))))
            for i in Tag_Id:
                if i not in mTag_Id:
                    index=Tag_Id(i)
                    l_global.append(l_local[index]]
                    points.append(plt.plot(function1(l_global[-1],1),function1(l_global[-1],2),'g',label="Tag:%s, X:%f, y: %f"%(function1(l_global[i],0),function1(l_global[i],1),function1(l_global[i],2))))

# import matplotlib.pyplot as plt
# import numpy as np

# x = np.linspace(0, 6*np.pi, 100)
# y = np.sin(x)

# # You probably won't need this if you're embedding things in a tkinter plot...
# plt.ion()

# fig = plt.figure()
# ax = fig.add_subplot(11)1
# line1, = ax.plot(x, y, 'r-') # Returns a tuple of line objects, thus the comma

# for phase in np.linspace(0, 10*np.pi, 500):
    # line1.set_ydata(np.sin(x + phase))
    # fig.canvas.draw()
20
задан Josh Caswell 20 July 2013 в 23:41
поделиться