Data Visualization in Python: difficulty 3

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

A student measures the speed v of a damped oscillator at times t from 0 to 12 s, with uncertainties in the array dv, and compares them with a model evaluated as v_model. The plotting code is

fig, ax = plt.subplots()
ax.plot(t, v)
ax.plot(t, v_model)
ax.set_title('data')
ax.set_xlim(0, 0.5)
plt.savefig('out.png')

The student concludes that the model fits well, because in the saved figure the two curves lie almost on top of one another.

Answer all four parts.

  1. Explain what is wrong with representing the measured data using ax.plot(t, v), and write the corrected call that also displays the uncertainties.
  2. The figure has no axis labels. State the convention for labelling a physics axis and write both calls, for time in seconds and speed in metres per second.
  3. Two series are drawn but the figure has no legend. Explain why this matters here in particular, and give the code needed to produce one.
  4. Explain why the student's conclusion is not supported, identifying the specific feature of the code responsible, and describe one change to the figure that would make the comparison between data and model honest.
Anatomy of a physics figure: markers with vertical uncertainty bars for the measured values, a continuous curve for the model, tick marks and numerals on both axes, axis labels carrying quantity and unit, and a legend identifying the two series.

Anatomy of a physics figure: markers with vertical uncertainty bars for the measured values, a continuous curve for the model, tick marks and numerals on both axes, axis labels carrying quantity and unit, and a legend identifying the two series.

Pendulum period against length, logarithmic axes

Pendulum period against length, logarithmic axes

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Data Visualization in Python Questions: