matplotlib

Reading

Read this tutorial up to but not including the section called “Working with text.”

Key ideas

Active learning

Activity 1

Download graph.py

  • Modify graphs.py to label the x-axis as x and the y-axis as y.
  • Modify graphs.py to plot the straight lines with magenta dashes. Hint.
  • Modify graphs.py to draw the sine wave with 5 point size.
  • Add your own function plot_new_func that plots a different sort of function on the same plot. Comment your function using a docstring.

Activity 2

Download diceSimulator.py.

  • change the simulator to roll 3 dice and display the results.
  • change the simulator to roll 10,000 times.

Acitivty 3

Download montana.py and montana.txt.

  • Modify the program above so that it shows the net population increase (or decrease) from one census date to the next in a second figure. (The first figure should continue to show the original graph.)