User Tools

Site Tools


Lab 0 - Learning MatPlotLib

You'll use Terminal and a web browser for this lab. Note: I strongly recommend creating a new directory for your CS415 work, and a subdirectory within it for your lab files.

  1. Start a Jupyter Notebook
    • in Terminal, change to your lab directory
    • enter the command jupyter notebook
    • if the command fails, try the full pathname: /usr/local/anaconda3/bin/jupyter notebook
    • In the webpage that opens up, click the New button and choose Python 3
  2. At the top of the new notebook page, it says Untitled. Click this text to rename it to Lab 0
  3. There is a dropdown menu in the toolbar that says Code. Select Markdown instead.
  4. In the first input box type ## Lab 0 - Prof Carl except with your name instead of mine ;^). Type Ctrl-Enter to make this your heading.
  5. Work through the MatPlotLib tutorial at, following these guidelines:
    • Other than the last (longest) example, enter each script by hand (do not cut-and-paste), one per In: box.
    • in a Notebook, you can enter the import statement for pyplot just once, not repeatedly as they do in tutorial
    • to run each script, type Ctrl-Enter inside the In: box. The first one may take a minute.
    • ensure your output matches the output in the tutorial examples
    • make sure you understand the basic idea behind each command
  6. Now replicate the following graph as closely as you can using the data below. Hint: plot will give you the blue line but no stars. To get those, combine plot with scatter; see the docs on scatter and legend commands
  7. Make the same graph, but flip the axes so numthreads is the x-axis. Which view makes more sense? Play with the graph by changing the color and style of the points and lines.
  8. From the File menu, choose Download as and HTML. Add a CS415 subdirectory to your html folder and copy the generated HTML page to the new folder.
  9. Back in the Notebook, from the File menu choose Close and Halt to shut down the Python kernel. Then you can click Logout on the main Notebook page.
  10. Back in Terminal, you can type <ctrl-c> twice to terminate the Jupyter server.


numThreads = [1,2,3,4]
real = [3.20, 1.68, 1.14, 0.95]
cs415pdc/lab0.txt · Last modified: 2022/01/19 16:22 by scarl