Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b01579

Browse files
committed
Added a ps.pagesize option to .matplotlibrc
svn path=/trunk/matplotlib/; revision=1240
1 parent 28641bc commit 8b01579

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed

.matplotlibrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ tk.window_focus : False # Maintain shell focus for TkAgg
176176
tk.pythoninspect : False # tk sets PYTHONINSEPCT
177177

178178
# ps backend params
179+
ps.papersize : letter # executive, letter, legal, ledger, A0-A10, B0-B6, C0-C6
179180
ps.useafm : False # use of afm fonts -- breaks mathtext but results in small files
180181

181182
# Set the verbose flags. This controls how much information

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-04-27 Set postscript page size in .matplotlibrc - DSD
4+
35
2005-04-26 Added embedding in qt example.
46

57
2005-04-14 Applied Michael Brady's qt backend patch: 1) fix a bug

lib/matplotlib/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ def validate_verbose_fileo(s):
451451
else:
452452
verbose.fileo = fileo
453453
return verbose.fileo
454+
455+
456+
def validate_ps_papersize(s):
457+
papertypes = ['executive', 'letter', 'legal', 'ledger', 'a0', 'a1', 'a2', 'a3', 'a4',
458+
'a5', 'a6', 'a7', 'a8', 'a9', 'a10', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5',
459+
'b6', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6']
460+
if s.lower() in papertypes:
461+
return s.lower()
462+
else:
463+
raise ValueError('ps.papersize must be one of: %s'% ', '.join(papertypes))
454464

455465

456466
# a map from key -> value, converter
@@ -552,6 +562,7 @@ def validate_verbose_fileo(s):
552562

553563
'tk.window_focus' : [ False, validate_bool], # Maintain shell focus for TkAgg
554564
'tk.pythoninspect' : [ False, validate_bool], # Set PYTHONINSPECT
565+
'ps.papersize' : [ 'letter', validate_ps_papersize], # Set the papersize/type
555566
'ps.useafm' : [ False, validate_bool], # Set PYTHONINSPECT
556567
'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate
557568

lib/matplotlib/backends/backend_ps.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,40 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
3131
import re
3232

3333
backend_version = 'Level II'
34-
defaultPaperSize = 8.5,11 # TODO: make this configurable
35-
debugPS = 1
36-
3734

35+
debugPS = 1
3836

37+
papersize = {'executive': (7.5,11),
38+
'letter': (8.5,11),
39+
'legal': (8.5,14),
40+
'ledger': (11,17),
41+
'a0': (33.11,46.81),
42+
'a1': (23.39,33.11),
43+
'a2': (16.54,23.39),
44+
'a3': (11.69,16.54),
45+
'a4': (8.27,11.69),
46+
'a5': (5.83,8.27),
47+
'a6': (4.13,5.83),
48+
'a7': (2.91,4.13),
49+
'a8': (2.07,2.91),
50+
'a9': (1.457,2.05),
51+
'a10': (1.02,1.457),
52+
'b0': (40.55,57.32),
53+
'b1': (28.66,40.55),
54+
'b2': (20.27,28.66),
55+
'b3': (14.33,20.27),
56+
'b4': (10.11,14.33),
57+
'b5': (7.16,10.11),
58+
'b6': (5.04,7.16),
59+
'c0': (36.10,51.06),
60+
'c1': (25.51,36.10),
61+
'c2': (18.03,25.51),
62+
'c3': (12.75,18.03),
63+
'c4': (9.01,12.75),
64+
'c5': (6.38,9.01),
65+
'c6': (4.49,6.38)}
66+
defaultPaperType = rcParams['ps.papersize']
67+
defaultPaperSize = papersize[defaultPaperType]
3968

4069
def _num_to_str(val):
4170
if is_string_like(val): return val
@@ -334,7 +363,6 @@ def _draw_markers(self, gc, path, rgbFace, x, y, transform):
334363
# construct the generic marker command:
335364
ps_cmd = ['gsave']
336365
ps_cmd.append('newpath')
337-
## ps_cmd.append('%1.3f %1.3f translate')
338366
ps_cmd.append('translate')
339367
while 1:
340368
code, xp, yp = path.vertex()
@@ -357,6 +385,7 @@ def _draw_markers(self, gc, path, rgbFace, x, y, transform):
357385
else:
358386
pass
359387
#print code
388+
360389
if rgbFace:
361390
ps_cmd.append('gsave')
362391
ps_cmd.append(ps_color)
@@ -369,21 +398,15 @@ def _draw_markers(self, gc, path, rgbFace, x, y, transform):
369398
#self._pswriter.write(' '.join(['/marker {', ps_cmd, '} bind def\n']))
370399
#self._pswriter.write('[%s]' % ';'.join([float(val) for val in vec6]))
371400
# Now evaluate the marker command at each marker location:
372-
## points = zip(x,y)
373401
start = 0
374402
end = 1000
375403
while start < len(x):
376404

377405
to_draw = izip(x[start:end],y[start:end])
378-
## ps = [ps_cmd % point for point in to_draw]
379406
ps = ['%1.3f %1.3f marker' % point for point in to_draw]
380407
self._draw_ps("\n".join(ps), gc, None)
381408
start = end
382409
end += 1000
383-
384-
## draw_ps = self._draw_ps
385-
## for xp,yp in izip(x,y):
386-
## draw_ps(ps_cmd % (xp,yp), gc, None)
387410

388411
def draw_path(self,gc,rgbFace,path,trans):
389412
pass
@@ -905,6 +928,7 @@ def print_figure(self, outfile, dpi=72,
905928
else:
906929
ostr="Portrait"
907930
print >>fh, "%%Orientation: "+ostr
931+
print >>fh, "%%DocumentPaperSizes: "+defaultPaperType
908932
print >>fh, "%%%%BoundingBox: %d %d %d %d" % (llx, lly, urx, ury)
909933
if not isEPSF: print >>fh, "%%Pages: 1"
910934
print >>fh, "%%EndComments"

0 commit comments

Comments
 (0)