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!

10 thoughts on “Class 3 – Make a list and plot it

  1. This class was a good foundation for graphing to build off of throughout the semester. Lists continued to be relevant as what we were doing in class got progressively more difficult, and the list of different ways of sorting in the “list notebook” was something I continued to return to as it lays out the formatting commands in a clear and concise way.

  2. I really like this section because you took your time going through the different was to get numbers in a list. One thing that I struggled with a lot was ( vs [ vs { and np.array uses brackets so I would really emphasize this point and start getting people use to that. I really also enjoyed the video and your introduction of how to make a really basic graph! I remember I was proud of myself that I actually coded and made a graph!

  3. This class was extremely productive and introduced us to arrays, while re-iterating the plot functions and allowing us to mess with the fancy types of graphing. The directions were very vivid and challenged us sufficiently. Overall, great class. But, if I have to help one more farm girl fill her holes and remove her piles, I am going to have an aneurism.

  4. I thought it was very useful to learn the difference between lists and arrays. However, having clear definitions of lists and arrays (and also strings) would be helpful to further understand the differences between them and when to use them. I also really enjoyed playing around with different colors and shapes in this class!

  5. This was a great class because it introduced us to plotting, which I used in almost every notebook for the remainder of the semester. It also introduced us to manipulating data within plotting, including a sneak peak into selecting specific parts of data to plot. I’m not sure how this session of the class could improve

  6. I enjoyed this lecture because it was a simple introduction to plotting, which became the foundation of all future lectures. It was interesting to see how one line of code in Python could create a plot while making the same plot in Excel would take many more steps. I also liked that each part was gone through step by step, no matter how minor. This way, I was actually able to understand what I was doing and I was able to see how each step used and built upon the one before it.

  7. This was a good review of making and adjusting lists with well thought out puzzles for us to solve. It was nice to do this before starting to practice plotting simply. The homework for this class was also a good one– fun to start seeing figures appear.

    Code.org was also a good tool to use at this point.

  8. I ended up going back to the notes and assignment for this class most frequently because it was a good introduction to matplotlib. It also taught me how to look for ways to make prettier graphs, which was definitely an important part of this course. I second the suggestion from above to put more info about matplotlib options in the actual classnotes.

  9. I remember this being a really cool class. For me the main draw was that I realized how much more efficient plotting in this way could be than plotting in Excel (or similar).

    This may be a pretty superficial suggestion, but the link to the website that goes through different lines, shapes, etc to use in your graphs (http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.plot), I find myself referencing all the time (since we do so much graphing!). I think it would be nice to also embed this link/a screenshot in the notebook (like how the loc, iloc, and dot notation summary sheet was in the first Pandas workbook). A little cheat sheet like that may be easier to quickly pull up and reference?

    I ended up taking some screenshots of the site and adding them to my workbook and found that to be helpful. Looking at that page a lot whenever I was going back and doing graphs helped me remember more features so that I could learn to use them without referencing the external site.

    –Jennifer Olson

  10. I enjoyed this class because it was an easy and comprehensive introduction to the how to form graphs. This was also the first time that I realized how specific your commands must be to create anything in python. Although code.org was not my favorite part, I think that it was important to do. It forced me to break down every action. However, I do think that the 20 hour code was a little excessive I think that doing the first 10 hours was enough.

Leave a Reply