Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

Students also viewed these Databases questions