Class 3 – Make a list and plot it

Today we are going to
1.  learn more about lists and then plot them (pdf=Lists Combined with Plotting)

Here is a reading on lists.  http://www.tutorialspoint.com/python/python_lists.htm

VIDEO

QUIZ After Video-Take the quiz on courseworks.

HOMEWORK

Homework 2 Due beginning of next class (Monday January 29, 2024).

  1. Code.org intro course through stage 15
  2. Make plots Like below.
  3. Hand in your notebook.  It ends in .ipynb.  this lets me run your notebook if there are any issues.

Make 2 lists

x=np.array([1,2,3,4,5,6])
y=np.array([6,5,4,3,2,1])

plot x versus y.

You will need to add this to the top of your code

 

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

The matplotlib inline tells the ipython notebook to show the graphs.  The import import matplotlib.pyplot as plt tells python to import the plotting package so we can use the plotting functions and make great plots.

Make an x,y plot using ax.plot.

Using the links in today’s notebook for ideas.

  1. choose your favorite shape
  2. choose your favorite color
  3. choose your favorite linestyle.
  4. choose something else to change (e.g. linewidth…)

here is my example-

What are the axes missing?

Add axis labels and a title?

Make sure to use Markdown to put your name and section at the beginning of the HW file and a description of the assignment

Use Markdown to add a figure caption.  This one can be brief but get in the habit.

 

This is my example but it is not perfect!!!!!  something similar without the missing parts will get you a 50.

x=np.array([1,2,3,4,5,6])
y=np.array([6,5,4,3,2,1])

fig,ax=plt.subplots()
ax.plot(x,y,marker=’^’,color=’r’,markersize=10,markeredgecolor=’g’,markeredgewidth=10,linestyle=’–‘)

hw2-picture
Final 10%:  To get the final 10% of the HW credit can you make a second plot with a slope of 4 and an intercept of 1?  Remember all the parts of the first graph.  Also, remember copy and paste are your friends……  Also remember what slope and intercept are!