Colorbar configuration
📖 Scenario: You are working with a heatmap that shows temperatures across a city grid. You want to add a colorbar to explain the colors to anyone looking at the map.
🎯 Goal: Create a heatmap using matplotlib and add a colorbar with a label and custom ticks to make the map easy to understand.
📋 What You'll Learn
Create a 2D list called
temperature_data with the exact values [[20, 22, 23], [21, 24, 25], [19, 20, 22]]Create a variable called
colorbar_label and set it to the string 'Temperature (°C)'Use
matplotlib.pyplot.imshow to display temperature_data as a heatmapAdd a colorbar to the heatmap with the label from
colorbar_labelSet the colorbar ticks to exactly [19, 21, 23, 25]
💡 Why This Matters
🌍 Real World
Colorbars help people understand what colors mean in heatmaps, like showing temperature, population density, or elevation on maps.
💼 Career
Data scientists and analysts use colorbars to make visualizations clear and easy to interpret for reports and presentations.
Progress0 / 4 steps