@@ -10,7 +10,6 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
10
10
from cStringIO import StringIO
11
11
from matplotlib import verbose , __version__ , rcParams
12
12
from matplotlib ._pylab_helpers import Gcf
13
- import matplotlib .agg as agg
14
13
from matplotlib .afm import AFM
15
14
from matplotlib .backend_bases import RendererBase , GraphicsContextBase ,\
16
15
FigureManagerBase , FigureCanvasBase
@@ -144,7 +143,7 @@ def __init__(self, width, height, pswriter, dpi=72):
144
143
self .image_magnification = dpi / 72.0
145
144
self ._clip_paths = {}
146
145
self ._path_collection_id = 0
147
-
146
+
148
147
self .fontd = {}
149
148
self .afmfontd = {}
150
149
self .used_characters = {}
@@ -332,7 +331,7 @@ def _get_font_ttf(self, prop):
332
331
size = prop .get_size_in_points ()
333
332
font .set_size (size , 72.0 )
334
333
return font
335
-
334
+
336
335
def _rgba (self , im ):
337
336
return im .as_rgba_str ()
338
337
@@ -406,7 +405,7 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
406
405
id = self ._get_clip_path (clippath , clippath_trans )
407
406
clip .append ('%s' % id )
408
407
clip = '\n ' .join (clip )
409
-
408
+
410
409
#y = figh-(y+h)
411
410
ps = """gsave
412
411
%(clip)s
@@ -427,7 +426,7 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
427
426
428
427
def _convert_path (self , path , transform ):
429
428
path = transform .transform_path (path )
430
-
429
+
431
430
ps = []
432
431
for points , code in path .iter_segments ():
433
432
if code == Path .MOVETO :
@@ -444,7 +443,7 @@ def _convert_path(self, path, transform):
444
443
elif code == Path .CLOSEPOLY :
445
444
ps .append ("cl" )
446
445
ps = "\n " .join (ps )
447
-
446
+
448
447
return ps
449
448
450
449
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)
489
488
ps_cmd .extend (['gsave' , ps_color , 'fill' , 'grestore' ])
490
489
491
490
ps_cmd .extend (['stroke' , 'grestore' , '} bind def' ])
492
-
491
+
493
492
tpath = trans .transform_path (path )
494
493
for x , y in tpath .vertices :
495
494
ps_cmd .append ("%1.3g %1.3g o" % (x , y ))
@@ -502,7 +501,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
502
501
offsetTrans , facecolors , edgecolors , linewidths ,
503
502
linestyles , antialiaseds ):
504
503
write = self ._pswriter .write
505
-
504
+
506
505
path_codes = []
507
506
for i , (path , transform ) in enumerate (self ._iter_collection_raw_paths (
508
507
master_transform , paths , all_transforms )):
@@ -513,7 +512,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
513
512
ps_cmd .extend (['} bind def\n
8000
' ])
514
513
write ('\n ' .join (ps_cmd ))
515
514
path_codes .append (name )
516
-
515
+
517
516
for xo , yo , path_id , gc , rgbFace in self ._iter_collection (
518
517
path_codes , cliprect , clippath , clippath_trans ,
519
518
offsets , offsetTrans , facecolors , edgecolors ,
@@ -523,7 +522,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
523
522
self ._draw_ps (ps , gc , rgbFace )
524
523
525
524
self ._path_collection_id += 1
526
-
525
+
527
526
def draw_tex (self , gc , x , y , s , prop , angle , ismath = 'TeX!' ):
528
527
"""
529
528
draw a Text instance
@@ -570,7 +569,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
570
569
571
570
elif isinstance (s , unicode ):
572
571
return self .draw_unicode (gc , x , y , s , prop , angle )
573
-
572
+
574
573
elif rcParams ['ps.useafm' ]:
575
574
font = self ._get_font_afm (prop )
576
575
@@ -654,7 +653,7 @@ def draw_unicode(self, gc, x, y, s, prop, angle):
654
653
kern = 0
655
654
last_name = name
656
655
thisx += kern * scale
657
-
656
+
658
657
lines .append ('%f %f m /%s glyphshow' % (thisx , thisy , name ))
659
658
660
659
thisx += width * scale
@@ -671,7 +670,7 @@ def draw_unicode(self, gc, x, y, s, prop, angle):
671
670
grestore
672
671
""" % locals ()
673
672
self ._pswriter .write (ps )
674
-
673
+
675
674
else :
676
675
font = self ._get_font_ttf (prop )
677
676
@@ -750,7 +749,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
750
749
(len (gc .get_rgb ()) <= 3 or gc .get_rgb ()[3 ] != 0.0 ))
751
750
fill = (fill and rgbFace is not None and
752
751
(len (rgbFace ) <= 3 or rgbFace [3 ] != 0.0 ))
753
-
752
+
754
753
if stroke :
755
754
self .set_linewidth (gc .get_linewidth ())
756
755
jint = gc .get_joinstyle ()
@@ -769,7 +768,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
769
768
if clippath :
770
769
id = self ._get_clip_path (clippath , clippath_trans )
771
770
write ('gsave\n %s\n ' % id )
772
-
771
+
773
772
# Jochen, is the strip necessary? - this could be a honking big string
774
773
write (ps .strip ())
775
774
write ("\n " )
@@ -795,7 +794,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
795
794
if cliprect :
796
795
write ("grestore\n " )
797
796
798
-
797
+
799
798
class GraphicsContextPS (GraphicsContextBase ):
800
799
def get_capstyle (self ):
801
800
return {'butt' :0 ,
@@ -821,16 +820,16 @@ def draw(self):
821
820
822
821
filetypes = {'ps' : 'Postscript' ,
823
822
'eps' : 'Encapsulated Postscript' }
824
-
823
+
825
824
def get_default_filetype (self ):
826
825
return 'ps'
827
-
826
+
828
827
def print_ps (self , outfile , * args , ** kwargs ):
829
828
return self ._print_ps (outfile , 'ps' , * args , ** kwargs )
830
829
831
830
def print_eps (self , outfile , * args , ** kwargs ):
832
831
return self ._print_ps (outfile , 'eps' , * args , ** kwargs )
833
-
832
+
834
833
def _print_ps (self , outfile , format , * args , ** kwargs ):
835
834
papertype = kwargs .get ("papertype" , rcParams ['ps.papersize' ])
836
835
papertype = papertype .lower ()
@@ -839,7 +838,7 @@ def _print_ps(self, outfile, format, *args, **kwargs):
839
838
elif papertype not in papersize :
840
839
raise RuntimeError ( '%s is not a valid papertype. Use one \
841
840
of %s'% (papertype , ', ' .join ( papersize .keys () )) )
842
-
841
+
843
842
orientation = kwargs .get ("orientation" , "portrait" ).lower ()
844
843
if orientation == 'landscape' : isLandscape = True
845
844
elif orientation == 'portrait' : isLandscape = False
@@ -849,14 +848,14 @@ def _print_ps(self, outfile, format, *args, **kwargs):
849
848
dpi = kwargs .get ("dpi" , 72 )
850
849
facecolor = kwargs .get ("facecolor" , "w" )
851
850
edgecolor = kwargs .get ("edgecolor" , "w" )
852
-
851
+
853
852
if rcParams ['text.usetex' ]:
854
853
self ._print_figure_tex (outfile , format , dpi , facecolor , edgecolor ,
855
854
orientation , isLandscape , papertype )
856
855
else :
857
856
self ._print_figure (outfile , format , dpi , facecolor , edgecolor ,
858
857
orientation , isLandscape , papertype )
859
-
858
+
860
859
def _print_figure (self , outfile , format , dpi = 72 , facecolor = 'w' , edgecolor = 'w' ,
861
860
orientation = 'portrait' , isLandscape = False , papertype = None ):
862
861
"""
0 commit comments