-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmatplotlib_intro.py
More file actions
92 lines (76 loc) · 3.12 KB
/
Copy pathmatplotlib_intro.py
File metadata and controls
92 lines (76 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# matplotlib_intro.py
"""Python Essentials: Intro to Matplotlib.
<Name>
<Class>
<Date>
"""
# Problem 1
def var_of_means(n):
"""Create an (n x n) array of values randomly sampled from the standard
normal distribution. Compute the mean of each row of the array. Return the
variance of these means.
Parameters:
n (int): The number of rows and columns in the matrix.
Returns:
(float) The variance of the means of each row.
"""
raise NotImplementedError("Problem 1 Incomplete")
def prob1():
"""Create an array of the results of var_of_means() with inputs
n = 100, 200, ..., 1000. Plot and show the resulting array.
"""
raise NotImplementedError("Problem 1 Incomplete")
# Problem 2
def prob2():
"""Plot the functions sin(x), cos(x), and arctan(x) on the domain
[-2pi, 2pi]. Make sure the domain is refined enough to produce a figure
with good resolution.
"""
raise NotImplementedError("Problem 2 Incomplete")
# Problem 3
def prob3():
"""Plot the curve f(x) = 1/(x-1) on the domain [-2,6].
1. Split the domain so that the curve looks discontinuous.
2. Plot both curves with a thick, dashed magenta line.
3. Set the range of the x-axis to [-2,6] and the range of the
y-axis to [-6,6].
"""
raise NotImplementedError("Problem 3 Incomplete")
# Problem 4
def prob4():
"""Plot the functions sin(x), sin(2x), 2sin(x), and 2sin(2x) on the
domain [0, 2pi], each in a separate subplot of a single figure.
1. Arrange the plots in a 2 x 2 grid of subplots.
2. Set the limits of each subplot to [0, 2pi]x[-2, 2].
3. Give each subplot an appropriate title.
4. Give the overall figure a title.
5. Use the following line colors and styles.
sin(x): green solid line.
sin(2x): red dashed line.
2sin(x): blue dashed line.
2sin(2x): magenta dotted line.
"""
raise NotImplementedError("Problem 4 Incomplete")
# Problem 5
def prob5():
"""Visualize the data in FARS.npy. Use np.load() to load the data, then
create a single figure with two subplots:
1. A scatter plot of longitudes against latitudes. Because of the
large number of data points, use black pixel markers (use "k,"
as the third argument to plt.plot()). Label both axes.
2. A histogram of the hours of the day, with one bin per hour.
Label and set the limits of the x-axis.
"""
raise NotImplementedError("Problem 5 Incomplete")
# Problem 6
def prob6():
"""Plot the function g(x,y) = sin(x)sin(y)/xy on the domain
[-2pi, 2pi]x[-2pi, 2pi].
1. Create 2 subplots: one with a heat map of g, and one with a contour
map of g. Choose an appropriate number of level curves, or specify
the curves yourself.
2. Set the limits of each subplot to [-2pi, 2pi]x[-2pi, 2pi].
3. Choose a non-default color scheme.
4. Include a color scale bar for each subplot.
"""
raise NotImplementedError("Problem 6 Incomplete")