Skip to content

Commit 8d28a94

Browse files
committed
Added plot of tanh
1 parent ade2413 commit 8d28a94

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

fig/chap3/tanh.png

22.9 KB
Loading

fig/chap3/tanh.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
tanh
3+
~~~~
4+
5+
Plots a graph of the tanh function."""
6+
7+
import numpy as np
8+
import matplotlib.pyplot as plt
9+
10+
z = np.arange(-5, 5, .1)
11+
t = np.tanh(z)
12+
13+
fig = plt.figure()
14+
ax = fig.add_subplot(111)
15+
ax.plot(z, t)
16+
ax.set_ylim([-1.0, 1.0])
17+
ax.set_xlim([-5,5])
18+
ax.grid(True)
19+
ax.set_xlabel('z')
20+
ax.set_title('tanh function')
21+
22+
plt.show()

0 commit comments

Comments
 (0)