Python Programming · High School (11–12) · 1 course, 10 worked problems, 20 practice questions
A graph shows a pattern that a table of numbers hides. The matplotlib library is the main plotting tool in Python. After import matplotlib.pyplot as plt, you can draw a line with plt.plot(x, y) and show it with plt.show(). A title, axis labels with units, a legend and grid lines make a graph easy to read. Other kinds of plot include scatter plots for experimental data, bar charts and histograms. A log scale shows data that changes over a wide range. With NumPy, matplotlib can plot a formula in a few lines.
plt.plot()Choose an answer, then check it. Each one shows a full explanation.
Which format string draws a green dashed line?
fig, axes = plt.subplots(2, 2). How many sets of axes does the figure have?
A detector counts 2500 clicks. What is the usual uncertainty of the count?
Which graph best shows the populations of five cities?
Each one has a hint, the key idea and a full worked solution.
Which graph shows how 500 measurements of one length are spread around their mean?
What must you do so that the labels of two lines appear on a graph?
Why does a curve drawn from 5 points look rough?
Ice cream sales and the number of swimmers at a beach have a correlation of 0.9. What does this show?
What does a straight line on a graph with a log scale on the y axis tell you about the data?
A student writes plt.plot(time, distance), where time has 11 numbers and distance has 10. What happens?