Page 297 - Touhpad Ai
P. 297
PRACTICAL FILE
1. Write a Python program demonstrating this using Matplotlib to create a line plot for visualizing the trend of a
dataset over time.
import matplotlib.pyplot as plt
days = list(range(1, 31))
temperatures = [ 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,32, 33, 32, 31, 30, 29,28, 27,
26, 25, 24, 23, 22, 21, 20, 21, 22, 23, 24, 25]
plt.plot(days, temperatures, marker='o', color='b', linestyle='-', label='Temperature
Trend')
plt.title('Average Daily Temperatures Over a Month')
plt.xlabel('Day of the Month')
plt.ylabel('Temperature (°C)')
plt.grid(True)
plt.legend()
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Output:
Practical File 295

