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

Skip to content

Commit a0bd5a4

Browse files
committed
don't link to example scripts to generate documentation figures
svn path=/trunk/matplotlib/; revision=5515
1 parent da3b9a4 commit a0bd5a4

6 files changed

Lines changed: 65 additions & 17 deletions

File tree

doc/devel/documenting_mpl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ automatically at build time to insure that the code that is included
110110
runs and produces the advertised figure. Several figures will be
111111
saved with the same basnename as the filename when the documentation
112112
is generated (low and high res PNGs, a PDF). Matplotlib includes a
113-
Sphinx extension (file:`sphinxext/plot_directive.py`) for generating
113+
Sphinx extension (:file:`sphinxext/plot_directive.py`) for generating
114114
the images from the python script and including either a png copy for
115115
html or a pdf for latex::
116116

doc/pyplots/make.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ def figs():
1717
for fname in glob.glob('*.py'):
1818
if fname==__file__: continue
1919
basename, ext = os.path.splitext(fname)
20-
outfiles = ['%s.%s' % (basename, format) for format, dpi in formats]
20+
imagefiles = dict([('../_static/%s.%s'%(basename, format), dpi)
21+
for format, dpi in formats])
2122
all_exists = True
22-
for format, dpi in formats:
23-
if not os.path.exists('%s.%s' % (basename, format)):
23+
for imagefile in imagefiles:
24+
if not os.path.exists(imagefile):
2425
all_exists = False
2526
break
2627

@@ -30,8 +31,8 @@ def figs():
3031
print ' building %s'%fname
3132
plt.close('all') # we need to clear between runs
3233
mplshell.magic_run(basename)
33-
for format, dpi in formats:
34-
plt.savefig('%s.%s' % (basename, format), dpi=dpi)
34+
for imagefile, dpi in imagefiles.iteritems():
35+
plt.savefig(imagefile, dpi=dpi)
3536
print 'all figures made'
3637

3738

doc/static_figs/make.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,43 @@
22
import sys, os, glob
33
import matplotlib
44
import IPython.Shell
5-
matplotlib.rcdefaults()
5+
#matplotlib.rcdefaults()
66
matplotlib.use('Agg')
77

88
mplshell = IPython.Shell.MatplotlibShell('mpl')
99

10+
formats = [('png', 100),
11+
('hires.png', 200),
12+
('pdf', 72)]
13+
1014
def figs():
1115
print 'making figs'
1216
import matplotlib.pyplot as plt
1317
for fname in glob.glob('*.py'):
1418
if fname.split('/')[-1] == __file__.split('/')[-1]: continue
1519
basename, ext = os.path.splitext(fname)
16-
outfile = '../_static/%s.png'%basename
20+
imagefiles = dict([('../_static/%s.%s'%(basename, format), dpi)
21+
for format, dpi in formats])
22+
all_exists = True
23+
for imagefile in imagefiles:
24+
if not os.path.exists(imagefile):
25+
all_exists = False
26+
break
1727

18-
if os.path.exists(outfile):
19-
print ' already have %s'%outfile
20-
continue
28+
if all_exists:
29+
print ' already have %s'%fname
2130
else:
2231
print ' building %s'%fname
23-
plt.close('all') # we need to clear between runs
24-
mplshell.magic_run(basename)
25-
plt.savefig(outfile)
32+
plt.close('all') # we need to clear between runs
33+
mplshell.magic_run(basename)
34+
for imagefile, dpi in imagefiles.iteritems():
35+
plt.savefig(imagefile, dpi=dpi)
2636
print 'all figures made'
2737

2838

2939
def clean():
30-
patterns = ['#*', '*~', '*.png', '*pyc']
40+
patterns = (['#*', '*~', '*pyc'] +
41+
['*.%s' % format for format, dpi in formats])
3142
for pattern in patterns:
3243
for fname in glob.glob(pattern):
3344
os.remove(fname)

doc/static_figs/tex_demo.png

-22.3 KB
Binary file not shown.

doc/static_figs/tex_demo.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/static_figs/tex_demo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from matplotlib import rc
2+
from numpy import arange, cos, pi
3+
from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \
4+
grid, savefig, show
5+
6+
7+
rc('text', usetex=True)
8+
rc('font', family='serif')
9+
figure(1, figsize=(6,4))
10+
ax = axes([0.1, 0.1, 0.8, 0.7])
11+
t = arange(0.0, 1.0+0.01, 0.01)
12+
s = cos(2*2*pi*t)+2
13+
plot(t, s)
14+
15+
xlabel(r'\textbf{time (s)}')
16+
ylabel(r'\textit{voltage (mV)}',fontsize=16)
17+
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
18+
fontsize=16, color='r')
19+
grid(True)

doc/static_figs/tex_unicode_demo.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: latin-1 -*-
2+
from matplotlib import rcParams
3+
rcParams['text.usetex']=True
4+
rcParams['text.latex.unicode']=True
5+
from numpy import arange, cos, pi
6+
from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \
7+
grid, savefig, show
8+
9+
figure(1, figsize=(6,4))
10+
ax = axes([0.1, 0.1, 0.8, 0.7])
11+
t = arange(0.0, 1.0+0.01, 0.01)
12+
s = cos(2*2*pi*t)+2
13+
plot(t, s)
14+
15+
xlabel(r'\textbf{time (s)}')
16+
ylabel(unicode(r'\textit{Velocity (°/sec)}','latin-1'),fontsize=16)
17+
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
18+
fontsize=16, color='r')
19+
grid(True)

0 commit comments

Comments
 (0)