CYB 135 Wk 5 – Practice: Reading

0 items
CYB 135 Wk 5 - Practice: Reading
CYB 135 Wk 5 – Practice: Reading
$5.00
  • Description

CYB 135 Wk 5 – Practice: Reading

Accurately complete all reading and Participation Activities to receive full points for this practice. You have unlimited attempts. The points you see in zyBooks do not reflect the points you receive in the gradebook.

The program imports the pyplot module from the matplotlib package, renaming matplotlib.pyplot to plt using the as keyword. The as keyword renames an imported module or package. The program then reads the temperatures from a file and stores the temperatures in a list. The plt.show() function displays the graph.

The plt.plot() function plots data onto the graph. plot() accepts various arguments. Above, two lists are passed to the function: The years list is the x-coordinate of each point to plot, and the temps list is the y-coordinate. plot() combines the lists into (x, y) coordinates. Above, years[0] is 1850 and temps[0] is -0.1, so plot() draws a point at (1850, -0.1). The next coordinate is (years[1], temps[1]), or (1851, -0.7). plot() also draws a line between successive points.

If provided just one list, as in plt.plot(temps), plot() uses 0, 1, … for x values, as in (0, temps[0]), (1, temps[1]), etc.

Calling plot multiple times draws multiple lines.