Custom colormaps
📖 Scenario: You are working with a heatmap that shows temperature data for a week. You want to make the colors more meaningful by creating your own color scale.
🎯 Goal: Create a custom colormap using matplotlib and apply it to a heatmap of temperature data.
📋 What You'll Learn
Create a 2D list called
temperatures with exact values for 7 days and 3 times per dayCreate a custom colormap named
my_cmap using LinearSegmentedColormap.from_list with specified colorsUse
plt.imshow with my_cmap to display the heatmapPrint the heatmap with
plt.colorbar() to show the color scale💡 Why This Matters
🌍 Real World
Custom colormaps help make data visualizations clearer and more meaningful, especially when showing temperature, elevation, or other continuous data.
💼 Career
Data scientists and analysts often create custom colormaps to highlight important data ranges and improve reports or dashboards.
Progress0 / 4 steps