diff --git a/solutions/1.1-limits.py b/solutions/1.1-limits.py new file mode 100644 index 0000000..37bf892 --- /dev/null +++ b/solutions/1.1-limits.py @@ -0,0 +1,3 @@ +fig, ax = plt.subplots(1, 1) +ax.set_ylim(1000, 500) +plt.show() diff --git a/solutions/1.2-spines.py b/solutions/1.2-spines.py new file mode 100644 index 0000000..ae58e32 --- /dev/null +++ b/solutions/1.2-spines.py @@ -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() diff --git a/solutions/2.1-colors.py b/solutions/2.1-colors.py new file mode 100644 index 0000000..8637ada --- /dev/null +++ b/solutions/2.1-colors.py @@ -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() diff --git a/solutions/2.2-markers.py b/solutions/2.2-markers.py new file mode 100644 index 0000000..533d96c --- /dev/null +++ b/solutions/2.2-markers.py @@ -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() diff --git a/solutions/2.3-properties.py b/solutions/2.3-properties.py new file mode 100644 index 0000000..340f787 --- /dev/null +++ b/solutions/2.3-properties.py @@ -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() diff --git a/solutions/2.4-arrows.py b/solutions/2.4-arrows.py new file mode 100644 index 0000000..9504857 --- /dev/null +++ b/solutions/2.4-arrows.py @@ -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() diff --git a/solutions/3.1-goldstar.py b/solutions/3.1-goldstar.py new file mode 100644 index 0000000..4057d05 --- /dev/null +++ b/solutions/3.1-goldstar.py @@ -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()