-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointPlotter.py
81 lines (62 loc) · 2.12 KB
/
PointPlotter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 31 14:21:56 2016
@author: user
"""
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 11 17:35:18 2012
@author: nrjh
"""
import matplotlib.pyplot as mp
from Polylines import Polyline
from Points import Point2D
class PointPlotter(object):
def PointFieldScatter(self,pointField,colour="black"):
x=[]
y=[]
ap=pointField.getPoints()
for point in ap:
x.append(point.get_x())
y.append(point.get_y())
mp.scatter(x,y,color=colour)
def show(self):
mp.show()
#end of function plotPoints
def plotPoint(self,point,colour='black'):
if isinstance(point,Point2D):
mp.scatter([point.get_x()],[point.get_y()],color=colour)
elif isinstance(point,list):
x=[]
y=[]
for p in point:
if isinstance(p,Point2D):
x.append(p.get_x())
y.append(p.get_y())
mp.scatter(x,y,color=colour)
def set_axis(self,xlo,xhi,ylo,yhi):
mp.axis([xlo,xhi,ylo,yhi])
mp.axis("equal")
def clf(self):
mp.clf()
def plotVector(self,p1,p2,colour='black'):
xs=[p1.get_x(),p2.get_x()]
ys=[p1.get_y(),p2.get_y()]
mp.plot(xs,ys,color=colour)
def plotSegment(self,seg,colour='black'):
p1=seg.getStart()
p2=seg.getEnd()
xs=[p1.get_x(),p2.get_x()]
ys=[p1.get_y(),p2.get_y()]
mp.plot(xs,ys,color=colour)
def plotPolylines(self,chains,colour='black'):
if isinstance(chains,Polyline):
xys=chains.getPointsAsLists()
mp.plot(xys[0],xys[1],color=colour)
elif isinstance(chains,list):
for chain in chains:
if isinstance(chain,Polyline):
xys=chain.getPointsAsLists()
mp.plot(xys[0],xys[1],color=colour)
def plotleaves(flownode,colur):
upnodes=flownode.