plotter/hpgl_mpl.py

changeset 40
1bbea188a7e5
parent 39
8becd52c2171
child 41
9a453b2479c5
equal deleted inserted replaced
39:8becd52c2171 40:1bbea188a7e5
1 # -*- coding: utf-8 -*-
2 import numpy
3 import pylab
4
5 from hpgl_parser import HPGLParser
6
7 class HPGLmplPlotter(HPGLParser):
8 pens = "krbgcmyw"
9 lines = ['-', ':', '--', '-.', '.', '-', '-', '-']
10 def __init__(self, data):
11 super(HPGLmplPlotter, self).__init__(data)
12 pylab.show()
13
14 def plot_symbols(self, points):
15 x, y = points.T
16 pylab.plot(x, y, 'o')
17
18 def plot_lines(self, points):
19 x, y = points.T
20 pylab.plot(x, y, self.pens[self.pen]+self.lines[self.line_type])
21
22 if __name__ == "__main__":
23 import sys
24 data = open(sys.argv[1]).read()
25 HPGLmplPlotter(data)
26

mercurial