Question: Install matplotlib on your machine: Windows: python - m pip install matplotlib Mac: pip 3 install - - user matplotlib Understand graphs.py Modify graphs.py to

Install matplotlib on your machine:
Windows: python -m pip install matplotlib
Mac: pip3 install --user matplotlib
Understand graphs.py
Modify graphs.py to label the x-axis as x and the y-axis as y.
Modify graphs.py to plot the straight lines with magenta dashes. Hint.
Modify graphs.py to draw the sine wave with 5 point size.
Modify graphs.py by replacing plt.xlim and plt.ylim (in the main function) with an equivalent plt.axis statement.
Reproduce this graph - scores.png as closely as possible.
Assumption: There are 10 students whose student IDs are 1 through 10.
graphs.py:
import matplotlib.pyplot as plt
import numpy as np
# --------------------------------------
def plot_line(x1, y1, x2, y2):
"""Plot a line using the specified points."""
x =[x1, x2]
y =[y1, y2]
plt.plot(x, y, "gold")
# --------------------------------------
def plot_sine_wave(start_x, stop_x, amplitude):
"""Plot a sine wave."""
x_array = np.linspace(start_x, stop_x,1000)
y_array = amplitude * np.sin(x_array)
plt.plot(x_array, y_array, "red")
# --------------------------------------
def main(graph_min, graph_max):
plt.xlim(graph_min, graph_max)
plt.ylim(graph_min, graph_max)
plot_line(graph_min, graph_min, graph_max, graph_max)
x_array = np.array([graph_min, graph_max])
y_array = np.array([graph_max, graph_min])
plt.plot(x_array, y_array, "blue")
plot_sine_wave(graph_min //2, graph_max //2, graph_max //4)
plt.show()
# --------------------------------------
main(-100,100)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!