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

Skip to content

Commit f5856aa

Browse files
committed
Merge pull request #4645 from ericmjl/mep12-text_handles.py
MEP12 on text_handles.py
2 parents 5795f8d + c9df0bc commit f5856aa

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

examples/pylab_examples/text_handles.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
# fonts. After all, if we were slaves to MATLAB , we wouldn't be
66
# using python!
77

8-
from pylab import *
8+
import matplotlib.pyplot as plt
9+
import numpy as np
910

1011

1112
def f(t):
12-
s1 = sin(2*pi*t)
13-
e1 = exp(-t)
14-
return multiply(s1, e1)
15-
16-
t1 = arange(0.0, 5.0, 0.1)
17-
t2 = arange(0.0, 5.0, 0.02)
13+
s1 = np.sin(2*np.pi*t)
14+
e1 = np.exp(-t)
15+
return np.multiply(s1, e1)
1816

17+
t1 = np.arange(0.0, 5.0, 0.1)
18+
t2 = np.arange(0.0, 5.0, 0.02)
1919

2020
fig, ax = plt.subplots()
21-
plot(t1, f(t1), 'bo', t2, f(t2), 'k')
22-
text(3.0, 0.6, 'f(t) = exp(-t) sin(2 pi t)')
23-
ttext = title('Fun with text!')
24-
ytext = ylabel('Damped oscillation')
25-
xtext = xlabel('time (s)')
26-
27-
setp(ttext, size='large', color='r', style='italic')
28-
setp(xtext, size='medium', name=['Courier', 'Bitstream Vera Sans Mono'],
21+
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
22+
plt.text(3.0, 0.6, 'f(t) = exp(-t) sin(2 pi t)')
23+
ttext = plt.title('Fun with text!')
24+
ytext = plt.ylabel('Damped oscillation')
25+
xtext = plt.xlabel('time (s)')
26+
27+
plt.setp(ttext, size='large', color='r', style='italic')
28+
plt.setp(xtext, size='medium', name=['Courier', 'Bitstream Vera Sans Mono'],
2929
weight='bold', color='g')
30-
setp(ytext, size='medium', name=['Helvetica', 'Bitstream Vera Sans'],
30+
plt.setp(ytext, size='medium', name=['Helvetica', 'Bitstream Vera Sans'],
3131
weight='light', color='b')
32-
show()
32+
plt.show()

0 commit comments

Comments
 (0)