def write_header(self): from matplotlib.backends.backend_ps import RendererPS, psDefs self.fd = open(self.filename, 'w') self.fd.write('%!PS-Adobe-3.0 EPSF-3.0\n') self.fd.write('%%Creator: G2\n') self.fd.write('%%CreationDate: %s\n' % time.ctime(time.time())) self.fd.write('%%Orientation: portrait\n') bbox = (0, 0, self.w, self.h) self.fd.write('%%%%BoundingBox: %d %d %d %d\n' % bbox) self.fd.write('%%EndComments\n') Ndict = len(psDefs) self.fd.write('%%BeginProlog\n') self.fd.write('/mpldict %d dict def\n' % Ndict) self.fd.write('mpldict begin\n') for d in psDefs: d = d.strip() for l in d.split('\n'): self.fd.write(l.strip() + '\n') self.fd.write('%%EndProlog\n') self.fd.write('mpldict begin\n') self.fd.write('%d %d 0 0 clipbox\n' % (self.w, self.h)) self.renderer = RendererPS(self.w, self.h, self.fd)
def write_header(self): import matplotlib if matplotlib.__version__ <= '0.8': raise RuntimeError('Your version of matplotlib (%s) is too old' % matplotlib.__version__) from matplotlib.backends.backend_ps import RendererPS, \ GraphicsContextPS, psDefs self.fd = open(self.filename, 'w') self.fd.write('%!PS-Adobe-3.0 EPSF-3.0\n') self.fd.write('%%Creator: G2\n') self.fd.write('%%CreationDate: %s\n' % time.ctime(time.time())) self.fd.write('%%Orientation: portrait\n') bbox = (0, 0, self.w, self.h) self.fd.write('%%%%BoundingBox: %d %d %d %d\n' % bbox) self.fd.write('%%EndComments\n') Ndict = len(psDefs) self.fd.write('%%BeginProlog\n') self.fd.write('/mpldict %d dict def\n' % Ndict) self.fd.write('mpldict begin\n') for d in psDefs: d = d.strip() for l in d.split('\n'): self.fd.write(l.strip() + '\n') self.fd.write('%%EndProlog\n') self.fd.write('mpldict begin\n') self.fd.write('%d %d 0 0 clipbox\n' % (self.w, self.h)) self.renderer = RendererPS(self.w, self.h, self.fd)
def _renderer(self, fd): # Subclass can override from matplotlib.backends.backend_ps import RendererPS return RendererPS(self.w, self.h, fd)