Question: import matplotlib.pyplot as plt def plot _ web _ traffic ( x , y , models = None ) : ' ' ' Plot the

import matplotlib.pyplot as plt
def plot_web_traffic(x, y, models=None):
'''
Plot the web traffic (y) over time (x).
If models is given, it is expected to be a list of fitted models,
which will be plotted as well (used later in this chapter).
'''
plt.figure (figsize=(12,6)) # width and height of the plot in inches
plt.scatter (x, y, s=10)
plt.title ("Web traffic over the last month")
Text(0.5,1.0, 'Web traffic over the last month')
plt.xlabel ("Time")
Text(0.5,47.04444444444444, 'Time')
plt.ylabel ("Hits/hour")
Text(85.06944444444443,0.5, 'Hits/hour')
plt.xticks([w*7*24 for w in range (5)],
['week %i'%(w+1) for w in range (5)])
([,,,,],[Text(0,0, 'week 1'), Text(168,0, 'week 2'), Text(336,0, 'week 3'), Text(504,0, 'week 4'), Text(672,0, 'week 5')])
if models:
colors =['g','k','b','m','r']
linestyles =['-','-.','--',':','-']
mx = sp.linspace(0, x[-1],1000)
for model, style, color in zip(models, linestyles, colors):
plt.plot (mx, model(mx), linestyle=style, linewidth=2, c=color)
plt.legend (["d=%i"% m.order for m in models], loc="upper left")
plt.autoscale (tight=True) can you help me fix this code in python

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 Databases Questions!