English

Collect the minimum and maximum temperature of your city for a month and present it using a histogram plot.

Advertisements
Advertisements

Question

Collect the minimum and maximum temperature of your city for a month and present it using a histogram plot.

Code Writing
Advertisements

Solution

import matplotlib.pyplot as plt
min_temp = [19, 20, 19, 21, 22, 20, 19, 18, 19, 20, 21, 22, 20, 19, 21, 
            22, 23, 22, 21, 20, 19, 18, 19, 20, 21, 22, 20, 19, 20, 21]
max_temp = [31, 32, 33, 32, 31, 30, 31, 32, 33, 34, 33, 32, 31, 32, 33, 
            34, 35, 34, 33, 32, 31, 30, 31, 32, 33, 34, 32, 31, 32, 33]
plt.hist(min_temp, bins=5, color='blue', alpha=0.6, label='Minimum Temp')
plt.hist(max_temp, bins=5, color='red', alpha=0.6, label='Maximum Temp')
plt.title("Temperature Distribution Over a Month")
plt.xlabel("Temperature Range (°C)")
plt.ylabel("Frequency (Number of Days)")
plt.legend()
plt.show()
shaalaa.com
  Is there an error in this question or solution?
Chapter 4: Plotting Data using Matplotlib - Exercise [Page 135]

APPEARS IN

NCERT Informatics Practices [English] Class 12
Chapter 4 Plotting Data using Matplotlib
Exercise | Q 14. | Page 135
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×