Exercise: Plot styling

4.6.4. Exercise: Plot styling#

In Exercise: Plotting a series 2, using these data:

# Video camera data
t = [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0]  # seconds
p = [0.0, 8.9, 28.0, 45.2, 60.4, 67.4, 75.5, 86.2, 93.0, 95.3, 100.0]  # meters

# Timing gates data (placed at positions 0m, 25m, 50m, 75m and 100m)
timing_gates_time = [0.0, 2.65, 5.70, 10.25, 20.0]  # seconds

you generated the following figure:

_images/dbfb5638a64c2c63a459abb8cebc3e12f508453a9c3285662792fdfa724474be.png

You now need to print it in black and white for publication in a journal. To maximize the clarity of the figure, you want to use markers and line styles instead of grey shades.

Generate the figure again, but this time with these specifications:

  • The video camera curve must be a full, black line with square markers;

  • The timing gates curve must be a dashed, black line with round markers.

Hide code cell content
import matplotlib.pyplot as plt

plt.plot(t, p, "s-k")
plt.plot(timing_gates_time, [0, 25, 50, 75, 100], "o--k")
plt.title("Race profile of a sprinter")
plt.xlabel("Time (s)")
plt.ylabel("Position (m)")
plt.legend(["Video camera", "Timing gates"])
plt.grid(True);
_images/b72607f4df0e52632a2b368d70a34b6b534fb2313a7154fbebe6d3ac00ddff3f.png