0
0
NumPydata~30 mins

NumPy with Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Visualizing Temperature Data with NumPy and Matplotlib
📖 Scenario: You are a weather analyst who wants to visualize temperature changes over a week. You have daily temperature data and want to create a simple line chart to see the trend.
🎯 Goal: Build a Python program that uses NumPy to store temperature data and Matplotlib to plot a line chart showing temperature changes over 7 days.
📋 What You'll Learn
Create a NumPy array with exact temperature values
Create a NumPy array for days of the week
Plot a line chart with days on the x-axis and temperatures on the y-axis
Label the x-axis as 'Day', y-axis as 'Temperature (°C)', and add a title 'Weekly Temperature'
Display the plot
💡 Why This Matters
🌍 Real World
Weather analysts and scientists often use NumPy and Matplotlib to analyze and visualize temperature and climate data.
💼 Career
Data scientists and analysts use these tools daily to create clear visual reports that help decision-makers understand trends.
Progress0 / 4 steps
1
Create temperature data using NumPy
Import numpy as np and create a NumPy array called temperatures with these exact values: 22, 24, 19, 23, 25, 20, 21.
NumPy
Need a hint?

Use np.array([...]) to create the array with the given temperature values.

2
Create days array using NumPy
Create a NumPy array called days with these exact string values representing days of the week: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'.
NumPy
Need a hint?

Use np.array([...]) with the exact day strings inside quotes.

3
Plot the temperature data using Matplotlib
Import matplotlib.pyplot as plt. Use plt.plot(days, temperatures) to create a line chart showing temperature changes over the days.
NumPy
Need a hint?

Use plt.plot() with days as x and temperatures as y.

4
Add labels, title, and display the plot
Add x-axis label 'Day' using plt.xlabel(), y-axis label 'Temperature (°C)' using plt.ylabel(), and title 'Weekly Temperature' using plt.title(). Then display the plot using plt.show().
NumPy
Need a hint?

Use plt.xlabel('Day'), plt.ylabel('Temperature (°C)'), plt.title('Weekly Temperature'), and plt.show().