Skip to content

Commit

Permalink
Solutions added.
Browse files Browse the repository at this point in the history
  • Loading branch information
WeatherGod committed Jul 8, 2014
1 parent 86b0b73 commit 1b197fb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions solutions/1.1-limits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fig, ax = plt.subplots(1, 1)
ax.set_ylim(1000, 500)
plt.show()
12 changes: 12 additions & 0 deletions solutions/1.2-spines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fig, ax = plt.subplots(1, 1)
ax.plot([-2, 2, 3, 4], [-10, 20, 25, 5])

ax.spines['top'].set_position('center')
ax.spines['right'].set_position('center')
ax.tick_params(axis='both', direction='inout', length=10)

# Move the two remaining spines "out" away from the plot by 10 points
ax.spines['bottom'].set_position(('outward', 10))
ax.spines['left'].set_position(('outward', 10))

plt.show()
3 changes: 3 additions & 0 deletions solutions/2.1-colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
t = np.arange(0.0, 5.0, 0.2)
plt.plot(t, t, 'r', t, t**2, 'cyan', t, t**3, '0.7')
plt.show()
3 changes: 3 additions & 0 deletions solutions/2.2-markers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
t = np.arange(0.0, 5.0, 0.2)
plt.plot(t, t, "*y", t, t**2, "8m", t, t**3, "sg")
plt.show()
4 changes: 4 additions & 0 deletions solutions/2.3-properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
t = np.arange(0.0, 5.0, 0.1)
a = np.exp(-t) * np.cos(2*np.pi*t)
plt.plot(t, a, 'r:', marker='D', mfc='y')
plt.show()
9 changes: 9 additions & 0 deletions solutions/2.4-arrows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
t = np.arange(0.0, 5.0, 0.01)
s = np.cos(2*np.pi*t)
plt.plot(t, s, lw=2)

plt.annotate('local min', xy=(2.5, -1), xytext=(3.5, -1.5),
arrowprops=dict(arrowstyle='fancy', color='red', shrink=0.5))

plt.ylim(-2, 2)
plt.show()
13 changes: 13 additions & 0 deletions solutions/3.1-goldstar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import matplotlib.pyplot as plt
from matplotlib.collections import StarPolygonCollection

fig, ax = plt.subplots(1, 1)

offsets = zip([0.2, 0.4, 0.6, 0.8], [0.5] * 4)
collection = StarPolygonCollection(5,
offsets=offsets,
transOffset=ax.transData,
facecolors=['gold'],
sizes=[75])
ax.add_collection(collection)
plt.show()

0 comments on commit 1b197fb

Please sign in to comment.