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

Skip to content

Commit 9a7ba08

Browse files
committed
added the pyplot tutorial to the users guide
svn path=/trunk/matplotlib/; revision=5233
1 parent d877a27 commit 9a7ba08

14 files changed

Lines changed: 541 additions & 18 deletions

doc/users_guide/figures/dollar_ticks.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@
1414
tick.label2On = True
1515
tick.label2.set_color('green')
1616

17-
fig.savefig('dollar_ticks')
18-
plt.show()
19-
2017

doc/users_guide/figures/fig_axes_customize_simple.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,4 @@
2424
line.set_markeredgewidth(3)
2525

2626

27-
fig.savefig('fig_axes_customize_simple')
2827

29-
plt.show()

doc/users_guide/figures/fig_axes_labels_simple.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,4 @@
1616
facecolor='yellow', edgecolor='yellow')
1717
ax2.set_xlabel('time (s)')
1818

19-
fig.savefig('fig_axes_labels_simple')
2019

21-
plt.show()

doc/users_guide/figures/fig_x.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99

1010
fig.lines.extend([l1, l2])
1111

12-
fig.savefig('fig_x')
13-
plt.show()
12+

doc/users_guide/figures/make.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
#!/usr/bin/env python
22
import sys, os, glob
33
import matplotlib
4+
import IPython.Shell
45
matplotlib.rcdefaults()
56
matplotlib.use('Agg')
67

7-
def figs():
8-
# each one of these will make a figure when imported
9-
import dollar_ticks
10-
import fig_axes_customize_simple
11-
import fig_axes_labels_simple
12-
import fig_x
8+
mplshell = IPython.Shell.MatplotlibShell('mpl')
139

10+
def figs():
11+
print 'making figs'
12+
import matplotlib.pyplot as plt
13+
for fname in glob.glob('*.py'):
14+
if fname==__file__: continue
15+
basename, ext = os.path.splitext(fname)
16+
outfile = '%s.png'%basename
17+
18+
if os.path.exists(outfile):
19+
print ' already have %s'%outfile
20+
continue
21+
else:
22+
print ' building %s'%fname
23+
plt.gcf().clf() # we need to clear between runs
24+
mplshell.magic_run(basename)
25+
plt.savefig('%s.png'%basename)
1426
print 'all figures made'
15-
for fname in glob.glob('*.pyc'):
16-
os.remove(fname)
27+
1728

1829
def clean():
19-
patterns = ['#*', '*~', '*.png']
30+
patterns = ['#*', '*~', '*.png', '*pyc']
2031
for pattern in patterns:
2132
for fname in glob.glob(pattern):
2233
os.remove(fname)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import matplotlib.pyplot as plt
2+
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
3+
plt.axis([0, 6, 0, 20])
4+
5+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
t = np.arange(0.0, 2.0, 0.01)
4+
s = np.sin(2*np.pi*t)
5+
6+
plt.plot(t,s)
7+
plt.title(r'$\alpha_i > \beta_i$', fontsize=20)
8+
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
9+
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
10+
fontsize=20)
11+
plt.xlabel('time (s)')
12+
plt.ylabel('volts (mV)')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import matplotlib.pyplot as plt
2+
plt.plot([1,2,3])
3+
plt.ylabel('some numbers')
4+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
mu, sigma = 100, 15
5+
x = mu + sigma * np.random.randn(10000)
6+
7+
# the histogram of the data
8+
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
9+
10+
11+
plt.xlabel('Smarts')
12+
plt.ylabel('Probability')
13+
plt.title('Histogram of IQ')
14+
plt.text(85, .025, r'$\mu=100,\ \sigma=15$')
15+
plt.axis([40, 160, 0, 0.03])
16+
plt.grid(True)
17+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
# evenly sampled time at 200ms intervals
5+
t = np.arange(0., 5., 0.2)
6+
7+
# red dashes, blue squares and green triangles
8+
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
9+

0 commit comments

Comments
 (0)