0
0
Matplotlibdata~30 mins

Colormaps (sequential, diverging, qualitative) in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Exploring Colormaps with Matplotlib
📖 Scenario: You are working with data visualization to make charts easier to understand. Colors help show differences and patterns in data. Matplotlib has special color sets called colormaps. These colormaps come in three types: sequential, diverging, and qualitative.Sequential colormaps show data that goes from low to high. Diverging colormaps highlight values that move away from a middle point. Qualitative colormaps use different colors to show categories without order.
🎯 Goal: You will generate and print colors using a sequential colormap in Matplotlib. This will help you see how colors change with data and how to pick the right colormap for your chart.
📋 What You'll Learn
Create a list of numbers from 0 to 9
Create a variable for a sequential colormap name
Generate colors from the colormap using normalized values from the numbers
Print the list of colors generated
💡 Why This Matters
🌍 Real World
Choosing the right colormap helps make data charts clear and easy to understand. For example, showing temperature changes or survey categories with colors.
💼 Career
Data scientists and analysts use colormaps to highlight important patterns and differences in data visualizations for reports and presentations.
Progress0 / 4 steps
1
Create a list of numbers from 0 to 9
Create a list called numbers that contains the integers from 0 to 9 inclusive.
Matplotlib
Need a hint?

Use the range() function to create numbers from 0 to 9, then convert it to a list.

2
Set a sequential colormap name
Create a variable called seq_cmap and set it to the string 'Blues', which is a sequential colormap in Matplotlib.
Matplotlib
Need a hint?

Just assign the string 'Blues' to the variable seq_cmap.

3
Generate colors from the sequential colormap
Import matplotlib.pyplot as plt. Use plt.get_cmap(seq_cmap) to get the colormap. Then create a list called colors by applying the colormap to each number normalized by dividing by 9 (the max number) for each n in numbers.
Matplotlib
Need a hint?

Use a list comprehension to apply the colormap to each normalized number.

4
Print the list of colors
Print the variable colors to see the RGBA color values generated from the sequential colormap.
Matplotlib
Need a hint?

Use print(colors) to display the list of colors.