How to draw line between point using python -


how draw line between 2 or 3 point. have 2 text file, first text file list of posisition each point.

point    long    lat        115     12 b        89      13 c        100     13 etc. 

and second file this:

3, 4 a, b, c r, x, y v, p, o j, m, n 2, 3 q, s h, k t, w 4, 1 e, d, f, g 

and want draw lines pic:

what wannt draw

actually, i'm not sure code. code::

import psycopg2 import psycopg2.extensions import matplotlib.pyplot plt import itertools import collections import numpy np  def readrules(_dir):   #_dir = r'd:\s2\semester 3\tesis\phyton\hasil\hasil_20160116_09.12.11'    mydict = {}     open(os.path.join(_dir, 'rule3.csv'), 'rb') testfile:      line in testfile:         # first line next record "matrix size"         columns, rows = (int(x) x in strip_comment(line).split(','))         # next line header record         key = tuple(strip_comment(next(testfile)).split(','))         # next lines rows record         vals = [tuple(int(x) x in     strip_comment(next(testfile)).split(','))             _ in range(rows)]         mydict[key] = vals     #print(mydict) return mydict     data=getdatareference(cur)   # location each point mypoints={} mylines=[] mydict=readrules(_dir)  # print "value :", mydict.values() # print "key:", mydict.keys()  value in mydict.values():     x in value:         s in range(len(x)):             mypoints[x[s]]= data[x[s]][0]             #print x[s]         if len(x)>1:             mylines.append(x)  mypoints_reversed = collections.defaultdict(list) number, string in mypoints.items():     mypoints_reversed[string].append(number)  colors = plt.cm.spectral(np.linspace(0, 1, len(mypoints_reversed)))  myplt={} k, col in zip(mypoints_reversed.keys(),colors):     long=[]     lat=[]     x in mypoints_reversed[k]:         long.append(data[x][2])         lat.append(data[x][1])     myplt[k] =plt.plot( lat,long , 'o', markerfacecolor=col, markeredgecolor='k', markersize=10, label=k)  #plt.legend(myplt,mypoints_reversed.keys(),loc=3,ncol=2, mode="expand", borderaxespad=0.)  plt.legend(loc =3,ncol=2, borderaxespad=0.)  #print mylines  #plt.plot(getlistlat(mypoints.keys(),data), getlistlong(mypoints.keys(),data),'o')  point in mypoints:     #plt.annotate(getname(point,data), xy=getlatlong(point,data)) #print name of point     plt.annotate(point, xy=getlatlong(point,data)) line in mylines:     plotline(line[0],line[1],data) plt.show() 


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -