Skip to content

Commit 1b197fb

Browse files
committed
Solutions added.
1 parent 86b0b73 commit 1b197fb

7 files changed

+47
-0
lines changed

Diff for: solutions/1.1-limits.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fig, ax = plt.subplots(1, 1)
2+
ax.set_ylim(1000, 500)
3+
plt.show()

Diff for: solutions/1.2-spines.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fig, ax = plt.subplots(1, 1)
2+
ax.plot([-2, 2, 3, 4], [-10, 20, 25, 5])
3+
4+
ax.spines['top'].set_position('center')
5+
ax.spines['right'].set_position('center')
6+
ax.tick_params(axis='both', direction='inout', length=10)
7+
8+
# Move the two remaining spines "out" away from the plot by 10 points
9+
ax.spines['bottom'].set_position(('outward', 10))
10+
ax.spines['left'].set_position(('outward', 10))
11+
12+
plt.show()

Diff for: solutions/2.1-colors.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
t = np.arange(0.0, 5.0, 0.2)
2+
plt.plot(t, t, 'r', t, t**2, 'cyan', t, t**3, '0.7')
3+
plt.show()

Diff for: solutions/2.2-markers.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
t = np.arange(0.0, 5.0, 0.2)
2+
plt.plot(t, t, "*y", t, t**2, "8m", t, t**3, "sg")
3+
plt.show()

Diff for: solutions/2.3-properties.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
t = np.arange(0.0, 5.0, 0.1)
2+
a = np.exp(-t) * np.cos(2*np.pi*t)
3+
plt.plot(t, a, 'r:', marker='D', mfc='y')
4+
plt.show()

Diff for: solutions/2.4-arrows.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
t = np.arange(0.0, 5.0, 0.01)
2+
s = np.cos(2*np.pi*t)
3+
plt.plot(t, s, lw=2)
4+
5+
plt.annotate('local min', xy=(2.5, -1), xytext=(3.5, -1.5),
6+
arrowprops=dict(arrowstyle='fancy', color='red', shrink=0.5))
7+
8+
plt.ylim(-2, 2)
9+
plt.show()

Diff for: solutions/3.1-goldstar.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import matplotlib.pyplot as plt
2+
from matplotlib.collections import StarPolygonCollection
3+
4+
fig, ax = plt.subplots(1, 1)
5+
6+
offsets = zip([0.2, 0.4, 0.6, 0.8], [0.5] * 4)
7+
collection = StarPolygonCollection(5,
8+
offsets=offsets,
9+
transOffset=ax.transData,
10+
facecolors=['gold'],
11+
sizes=[75])
12+
ax.add_collection(collection)
13+
plt.show()

0 commit comments

Comments
 (0)