8000 Fix Ps import bug · mkcor/matplotlib@b00844a · GitHub
[go: up one dir, main page]

Skip to content

Commit b00844a

Browse files
committed
Fix Ps import bug
svn path=/branches/transforms/; revision=4494
1 parent 314289e commit b00844a

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
1010
from cStringIO import StringIO
1111
from matplotlib import verbose, __version__, rcParams
1212
from matplotlib._pylab_helpers import Gcf
13-
import matplotlib.agg as agg
1413
from matplotlib.afm import AFM
1514
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
1615
FigureManagerBase, FigureCanvasBase
@@ -144,7 +143,7 @@ def __init__(self, width, height, pswriter, dpi=72):
144143
self.image_magnification = dpi/72.0
145144
self._clip_paths = {}
146145
self._path_collection_id = 0
147-
146+
148147
self.fontd = {}
149148
self.afmfontd = {}
150149
self.used_characters = {}
@@ -332,7 +331,7 @@ def _get_font_ttf(self, prop):
332331
size = prop.get_size_in_points()
333332
font.set_size(size, 72.0)
334333
return font
335-
334+
336335
def _rgba(self, im):
337336
return im.as_rgba_str()
338337

@@ -406,7 +405,7 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
406405
id = self._get_clip_path(clippath, clippath_trans)
407406
clip.append('%s' % id)
408407
clip = '\n'.join(clip)
409-
408+
410409
#y = figh-(y+h)
411410
ps = """gsave
412411
%(clip)s
@@ -427,7 +426,7 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
427426

428427
def _convert_path(self, path, transform):
429428
path = transform.transform_path(path)
430-
429+
431430
ps = []
432431
for points, code in path.iter_segments():
433432
if code == Path.MOVETO:
@@ -444,7 +443,7 @@ def _convert_path(self, path, transform):
444443
elif code == Path.CLOSEPOLY:
445444
ps.append("cl")
446445
ps = "\n".join(ps)
447-
446+
448447
return ps
449448

450449
def _get_clip_path(self, clippath, clippath_transform):
@@ -489,7 +488,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
489488
ps_cmd.extend(['gsave', ps_color, 'fill', 'grestore'])
490489

491490
ps_cmd.extend(['stroke', 'grestore', '} bind def'])
492-
491+
493492
tpath = trans.transform_path(path)
494493
for x, y in tpath.vertices:
495494
ps_cmd.append("%1.3g %1.3g o" % (x, y))
@@ -502,7 +501,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
502501
offsetTrans, facecolors, edgecolors, linewidths,
503502
linestyles, antialiaseds):
504503
write = self._pswriter.write
505-
504+
506505
path_codes = []
507506
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
508507
master_transform, paths, all_transforms)):
@@ -513,7 +512,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
513512
ps_cmd.extend(['} bind def\n 8000 '])
514513
write('\n'.join(ps_cmd))
515514
path_codes.append(name)
516-
515+
517516
for xo, yo, path_id, gc, rgbFace in self._iter_collection(
518517
path_codes, cliprect, clippath, clippath_trans,
519518
offsets, offsetTrans, facecolors, edgecolors,
@@ -523,7 +522,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
523522
self._draw_ps(ps, gc, rgbFace)
524523

525524
self._path_collection_id += 1
526-
525+
527526
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!'):
528527
"""
529528
draw a Text instance
@@ -570,7 +569,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
570569

571570
elif isinstance(s, unicode):
572571
return self.draw_unicode(gc, x, y, s, prop, angle)
573-
572+
574573
elif rcParams['ps.useafm']:
575574
font = self._get_font_afm(prop)
576575

@@ -654,7 +653,7 @@ def draw_unicode(self, gc, x, y, s, prop, angle):
654653
kern = 0
655654
last_name = name
656655
thisx += kern * scale
657-
656+
658657
lines.append('%f %f m /%s glyphshow'%(thisx, thisy, name))
659658

660659
thisx += width * scale
@@ -671,7 +670,7 @@ def draw_unicode(self, gc, x, y, s, prop, angle):
671670
grestore
672671
""" % locals()
673672
self._pswriter.write(ps)
674-
673+
675674
else:
676675
font = self._get_font_ttf(prop)
677676

@@ -750,7 +749,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
750749
(len(gc.get_rgb()) <= 3 or gc.get_rgb()[3] != 0.0))
751750
fill = (fill and rgbFace is not None and
752751
(len(rgbFace) <= 3 or rgbFace[3] != 0.0))
753-
752+
754753
if stroke:
755754
self.set_linewidth(gc.get_linewidth())
756755
jint = gc.get_joinstyle()
@@ -769,7 +768,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
769768
if clippath:
770769
id = self._get_clip_path(clippath, clippath_trans)
771770
write('gsave\n%s\n' % id)
772-
771+
773772
# Jochen, is the strip necessary? - this could be a honking big string
774773
write(ps.strip())
775774
write("\n")
@@ -795,7 +794,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
795794
if cliprect:
796795
write("grestore\n")
797796

798-
797+
799798
class GraphicsContextPS(GraphicsContextBase):
800799
def get_capstyle(self):
801800
return {'butt':0,
@@ -821,16 +820,16 @@ def draw(self):
821820

822821
filetypes = {'ps' : 'Postscript',
823822
'eps' : 'Encapsulated Postscript'}
824-
823+
825824
def get_default_filetype(self):
826825
return 'ps'
827-
826+
828827
def print_ps(self, outfile, *args, **kwargs):
829828
return self._print_ps(outfile, 'ps', *args, **kwargs)
830829

831830
def print_eps(self, outfile, *args, **kwargs):
832831
return self._print_ps(outfile, 'eps', *args, **kwargs)
833-
832+
834833
def _print_ps(self, outfile, format, *args, **kwargs):
835834
papertype = kwargs.get("papertype", rcParams['ps.papersize'])
836835
papertype = papertype.lower()
@@ -839,7 +838,7 @@ def _print_ps(self, outfile, format, *args, **kwargs):
839838
elif papertype not in papersize:
840839
raise RuntimeError( '%s is not a valid papertype. Use one \
841840
of %s'% (papertype, ', '.join( papersize.keys() )) )
842-
841+
843842
orientation = kwargs.get("orientation", "portrait").lower()
844843
if orientation == 'landscape': isLandscape = True
845844
elif orientation == 'portrait': isLandscape = False
@@ -849,14 +848,14 @@ def _print_ps(self, outfile, format, *args, **kwargs):
849848
dpi = kwargs.get("dpi", 72)
850849
facecolor = kwargs.get("facecolor", "w")
851850
edgecolor = kwargs.get("edgecolor", "w")
852-
851+
853852
if rcParams['text.usetex']:
854853
self._print_figure_tex(outfile, format, dpi, facecolor, edgecolor,
855854
orientation, isLandscape, papertype)
856855
else:
857856
self._print_figure(outfile, format, dpi, facecolor, edgecolor,
858857
orientation, isLandscape, papertype)
859-
858+
860859
def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w',
861860
orientation='portrait', isLandscape=False, papertype=None):
862861
"""

0 commit comments

Comments
 (0)
0