Menu

[r6270]: / trunk / htdocs / screenshots / makeshots.py  Maximize  Restore  History

Download this file

71 lines (61 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
setenv TTFPATH ~/src/ttf_microsoft/
"""
import sys, os
default = 'Agg'
# do not remove the pngs - some are screenshots!
files = {
'wheeler_demo.py' : default,
'layer_images.py' : default,
'finance_work2.py' : default,
'simple_plot.py' : default,
'axes_demo.py' : default,
'histogram_demo.py' : default,
'mri_with_eeg.py' : default,
'fill_demo.py' : default,
'date_demo.py' : default,
'barchart_demo.py' : default,
'table_demo.py' : default,
'tex_demo.py' : default,
'legend_demo.py' : default,
'slider_demo.py' : default,
'mathtext_demo.py' : default,
'mathtext_examples.py' : default,
'pcolor_demo.py' : default,
'text_themes.py' : default,
'log_shot.py' : default,
'align_text.py' : default,
'scatter_demo2.py' : default,
'polar_demo.py' : default,
'pie_demo.py' : default,
'plotmap.py' : default,
'hstdemo.py' : default,
'path_patch_demo.py' : default,
'ellipse_demo.py' : default,
}
dpi1 = 60
dpi2 = 120
def make_shot(fname, backend):
lines = [
'from __future__ import division\n',
'import matplotlib\n',
'matplotlib.use("%s")\n' % backend,
'from pylab import *\n'
]
print '\tdriving %s' % fname
for line in file(fname):
if line.strip().startswith('from __future__ import division'): continue
if line.strip().startswith('matplotlib.use'): continue
if line.strip().startswith('savefig'): continue
if line.strip().startswith('from pylab import *'): continue
if line.strip().startswith('show'): continue
lines.append(line)
basename, ext = os.path.splitext(fname)
lines.append('savefig("%s_small", dpi=%d)\n' % (basename, dpi1))
lines.append('savefig("%s_large", dpi=%d)\n' % (basename, dpi2))
tmpfile = '_tmp_%s.py' % basename
file(tmpfile, 'w').write(''.join(lines))
os.system('python %s' % tmpfile)
#os.remove(tmpfile)
for fname, backend in files.items():
make_shot(fname, backend)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.