I’ve been working with Python, and one of the libraries I rely on the most for data visualization is Matplotlib. Scatter plots are a staple when it comes to exploring relationships between two variables. But what makes these plots stand out is how you use color to convey more information.
In this article, I’ll walk you through different ways to customize Matplotlib scatter plot colors. I’ll share practical tips from my own experience that will help you create clear and impactful visualizations.
Let’s get in!
Methods for Matplotlib Scatter Plot Color
Now, I will explain to you the methods to set the color for all the points.
Method 1: Set a Single Color for All Points
Sometimes, simplicity is key. If your goal is to plot points all in the same color, Matplotlib makes it easy. Here’s how I usually do it:
import matplotlib.pyplot as plt
x = [10, 20, 30, 40, 50]
y = [5, 15, 25, 35, 45]
plt.scatter(x, y, color='blue')
plt.title('Scatter Plot with Single Color')
plt.show()You can refer to the screenshot below to see the output.

This method is perfect when you want to emphasize the position of points without adding extra layers of information.
Method 2: Use Different Colors for Categories
If your data has categories, using different colors for each group can make patterns easier to spot. For example, imagine plotting sales data by region in the US, East, West, and Central.
import matplotlib.pyplot as plt
x = [10, 20, 30, 40, 50, 60]
y = [5, 15, 25, 35, 45, 55]
regions = ['East', 'West', 'East', 'Central', 'West', 'Central']
colors = {'East':'red', 'West':'green', 'Central':'blue'}
plt.scatter(x, y, c=[colors[region] for region in regions])
plt.title('Scatter Plot Colored by Region')
plt.show()You can refer to the screenshot below to see the output.

Assigning colors manually like this gives you full control over how each category appears.
Method 3: Apply Color Maps to Represent Continuous Data
When your data includes a continuous variable, such as population density or sales volume, color maps are a great way to visualize this. I often use the c parameter with a color map to represent such data.
Consider plotting store locations with sales volume represented by color intensity:
import matplotlib.pyplot as plt
import numpy as np
x = np.random.rand(50) * 100
y = np.random.rand(50) * 100
sales_volume = np.random.rand(50) * 1000 # Sales volume for each store
plt.scatter(x, y, c=sales_volume, cmap='viridis')
plt.colorbar(label='Sales Volume')
plt.title('Scatter Plot with Color Map for Sales Volume')
plt.show()You can refer to the screenshot below to see the output.

The color bar helps viewers understand the scale of the continuous variable.
Method 4: Customize Edge Colors and Transparency
To make your points pop, you can customize edge colors and add transparency. This is especially useful when points overlap.
plt.scatter(x, y, c='orange', edgecolor='black', alpha=0.7)
plt.title('Scatter Plot with Edge Colors and Transparency')
plt.show()Adding alpha (transparency) helps visualize dense clusters without losing individual points.
Check out Matplotlib Dashed Line
Method 5: Use Color Gradients for Time-Series or Ordered Data
If your scatter plot represents data over time or ordered sequences, a color gradient can be very effective. I usually use a sequential color map like plasma or coolwarm to show progression.
import matplotlib.pyplot as plt
import numpy as np
time = np.arange(50)
x = np.random.rand(50) * 100
y = np.random.rand(50) * 100
plt.scatter(x, y, c=time, cmap='plasma')
plt.colorbar(label='Time')
plt.title('Scatter Plot with Time Gradient')
plt.show()This technique visually encodes the temporal or sequential nature of the data.
Tips from My Experience
- Always include a color bar when using color maps to represent continuous data.
- Choose color maps that are colorblind-friendly if your audience includes diverse viewers.
- Avoid using too many colors for categorical data; it can confuse the viewer.
- Use transparency to handle overlapping points effectively.
- Experiment with edge colors to improve point visibility.
These small tweaks can dramatically improve how your scatter plots communicate insights.
Mastering scatter plot colors in Matplotlib is a skill that will elevate your data storytelling. With these methods, you can create visualizations that are both beautiful and meaningful, helping you and your audience make better data-driven decisions.
If you want to dive deeper into Matplotlib or explore other plotting techniques, keep experimenting and exploring the rich customization options available. Happy plotting!
You may also like other tutorials on Matplotlib:
- Python Plot Multiple Lines Using Matplotlib
- What is Matplotlib Inline in Python
- Matplotlib Best Fit Line

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.