plotter/hpgl_mpl.py

changeset 32
59da528bc470
parent 18
c691b040e8c9
equal deleted inserted replaced
31:c869766e25ff 32:59da528bc470
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