Comments
Python code is allowed to contain comments. These are lines which python ignores, so you can write anything you like. The comment symbol is #. Whenever you see #, the rest of the line is a comment. Example:
Numpy Arrays vs. Lists
When you want to store a set of numbers which go together, you need to use some kind of array. Python has a built in data type called lists. We prefer to use numpy arrays. This example should demonstrate the difference:
Creating Arrays With More Points, Smooth Curve Plots
In Part 1 we created the x variable by hand. To get a smoother graph with more points, we can use the command np.linspace(min, max, num_points). This creates an array with num_points evenly spaced points between min and max. For example:
Plots With Multiple Curves
It's easy to add more curves to your plot:
Multiple Figures
To create multiple figures within the same script, use the plt.figure() command:
That's it for now.
No comments:
Post a Comment