Question

Please use python codes thank you so much!!! I really need help!!! Create a plot showing...

Please use python codes thank you so much!!! I really need help!!!

Create a plot showing the monthly average temperature starting in January 2001 (one plot showing all data points from January 2001 through December 2003).

Year   Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec    
2001    42   43   55   50   56   54   60   48   53   50   69   55     
2002    75   75   89   56   63   55   61   53   62   55   58   43 
2003    73   55   57   53   60   47   53   65   64   74   52   73   
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#matplotlib is a module that contains ploting functions
import matplotlib.pyplot as plt
#MAT = Monthly Average Temperature
#x1 is the MAT of the year 2001
x1=[42, 43, 55, 50, 56, 54, 60, 48, 53, 50, 69, 55]
#x2 is the MAT of the year 2002
x2=[75, 75, 89, 56, 63, 55, 61, 53, 62, 55, 58, 43]
#x3 is the MAT of the year 2003
x3=[73, 55, 57, 53, 60, 47, 53, 65, 64, 74, 52, 73]
#these are used to add additional properties for the plot
i,j = plt.subplots()
#all the names of months are stored to label them on the X axis
months=['Jan', 'Feb', 'Mar', 'Apr', 'May','Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
#please open the output graph in full screen
#bar function is used to plot bar graph
#1st parameter is the X axis values
#2nd parameter is the Y axis values
#color is used to define the color of the bar
#label is used to define the colors for the resective years
plt.bar(list(range(1,13)),x1,color="green",label="2001")
plt.bar(list(range(13,25)),x2,color="red",label="2002")
plt.bar(list(range(25,37)),x3,color="blue",label="2003")
#set_xticklabels is used to set labels for X axis
#as there are 3 years each year has 12 months so months*3
j.set_xticklabels(months*3)
#xticks is used to define 36 labels
plt.xticks(list(range(1,37)))
plt.xlabel('Months of respective year')
plt.ylabel('Monthly average temperature')
plt.title('Temperature vs Months')
#legend is used to disply the label
plt.legend()
#show is used to display the plot
plt.show()
Screenshot:

Output:

Add a comment
Know the answer?
Add Answer to:
Please use python codes thank you so much!!! I really need help!!! Create a plot showing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT