Advertisements
Advertisements
प्रश्न
Collect the minimum and maximum temperature of your city for a month and present it using a histogram plot.
कोड लेखन
Advertisements
उत्तर
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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
