hpgl_mpl.py

Fri, 25 Jan 2008 20:50:50 +0100

author
David Douard <david.douard@logilab.fr>
date
Fri, 25 Jan 2008 20:50:50 +0100
changeset 30
1263eafdb953
parent 18
c691b040e8c9
permissions
-rw-r--r--

removed useless png files (using SVG everywhere)

# -*- coding: utf-8 -*-
import numpy
import pylab

from hpgl_parser import HPGLParser

class HPGLmplPlotter(HPGLParser):
    pens = "krbgcmyw"
    lines = ['-', ':', '--', '-.', '.', '-', '-', '-']
    def __init__(self, data):        
        super(HPGLmplPlotter, self).__init__(data)
        pylab.show()
        
    def plot_symbols(self, points):
        x, y = points.T
        pylab.plot(x, y, 'o')

    def plot_lines(self, points):
        x, y = points.T
        pylab.plot(x, y, self.pens[self.pen]+self.lines[self.line_type])
        
if __name__ == "__main__":
    import sys
    data = open(sys.argv[1]).read()
    HPGLmplPlotter(data)
    

mercurial