While working on a data visualization project for a U.S.-based sales dataset, I needed to make my scatter plots more informative and visually appealing. The default scatter plot looked too plain, and I wanted to highlight specific data points using different marker sizes and colors.
In Python, Matplotlib is one of my go-to libraries for creating professional and insightful visualizations. Over the years, I’ve learned that a few simple customizations, like adjusting marker size and color, can transform a basic scatter plot into a powerful storytelling tool.
In this tutorial, I’ll show you how to customize marker size and color in a Matplotlib scatter plot using simple and effective techniques. I’ll walk you through multiple methods for each, so you can choose the one that best fits your project.
Create a Basic Scatter Plot in Python
Before we get into customization, let’s first create a simple scatter plot using Python and Matplotlib.
Here’s a quick setup example:
import matplotlib.pyplot as plt
# Sample data: U.S. sales performance
sales = [100, 200, 300, 400, 500]
profit = [20, 40, 60, 80, 100]
plt.scatter(sales, profit)
plt.title("Basic Scatter Plot - U.S. Sales vs Profit")
plt.xlabel("Sales (in thousands USD)")
plt.ylabel("Profit (in thousands USD)")
plt.show()In the plot above, each point represents a data pair of sales and profit. It’s simple but lacks distinction. Let’s now enhance it by customizing the marker size and marker color.
Customize Marker Size in a Matplotlib Scatter Plot
Sometimes, you want to represent an additional variable using the size of the markers. For instance, in a business dataset, larger markers might represent higher revenue or customer count.
Method 1 – Set a Fixed Marker Size
If you want all markers to have the same size, you can simply use the s parameter in the plt.scatter() function.
import matplotlib.pyplot as plt
# Sample data
sales = [120, 250, 330, 410, 500]
profit = [25, 45, 70, 85, 110]
# Fixed marker size
plt.scatter(sales, profit, s=200, color='skyblue', edgecolors='black')
plt.title("Scatter Plot with Fixed Marker Size - U.S. Sales Data")
plt.xlabel("Sales (in thousands USD)")
plt.ylabel("Profit (in thousands USD)")
plt.show()You can refer to the screenshot below to see the output.

In this example, I set s=200, which means each marker will have the same size. This method works well when you want a uniform look across all data points.
Method 2 – Vary Marker Size Based on Data
If you want to make your scatter plot more meaningful, you can vary marker sizes based on another variable, such as customer count or product volume.
import matplotlib.pyplot as plt
# Sample data
sales = [120, 250, 330, 410, 500]
profit = [25, 45, 70, 85, 110]
customers = [15, 30, 45, 60, 75] # Number of customers (used for marker size)
# Marker size based on customers
plt.scatter(sales, profit, s=[c * 10 for c in customers], color='orange', alpha=0.7, edgecolors='black')
plt.title("Scatter Plot with Variable Marker Size - U.S. Customer Data")
plt.xlabel("Sales (in thousands USD)")
plt.ylabel("Profit (in thousands USD)")
plt.show()You can refer to the screenshot below to see the output.

Here, I multiplied each customer count by 10 to make the size visually noticeable. The alpha parameter adds transparency, making overlapping points easier to see.
Customize Marker Color in a Matplotlib Scatter Plot
Color can add another dimension to your visualization. You can use colors to represent categories, highlight trends, or emphasize specific data points.
Let’s explore two ways to control marker color in Python’s Matplotlib.
Method 1 – Set a Fixed Marker Color
If you want all points to have the same color, you can simply specify it using the color parameter.
import matplotlib.pyplot as plt
# Sample data
sales = [150, 230, 310, 420, 510]
profit = [30, 50, 75, 95, 120]
# Fixed color
plt.scatter(sales, profit, color='green', s=150, edgecolors='black')
plt.title("Scatter Plot with Fixed Marker Color - U.S. Sales Overview")
plt.xlabel("Sales (in thousands USD)")
plt.ylabel("Profit (in thousands USD)")
plt.show()You can refer to the screenshot below to see the output.

In this example, all markers are green. This works well when you’re presenting a single dataset or want a clean, consistent look.
Method 2 – Assign Colors Dynamically Based on Data
When you want to represent another variable using color, you can use the c parameter along with a colormap (cmap). This is especially useful for visualizing gradients or intensity.
import matplotlib.pyplot as plt
import numpy as np
# Sample data
sales = np.array([150, 230, 310, 420, 510])
profit = np.array([30, 50, 75, 95, 120])
growth_rate = np.array([5, 10, 15, 20, 25]) # Growth rate in percentage
# Color based on growth rate
plt.scatter(sales, profit, c=growth_rate, cmap='viridis', s=200, edgecolors='black')
plt.colorbar(label="Growth Rate (%)")
plt.title("Scatter Plot with Variable Marker Color - U.S. Growth Analysis")
plt.xlabel("Sales (in thousands USD)")
plt.ylabel("Profit (in thousands USD)")
plt.show()You can refer to the screenshot below to see the output.

In this example, the color of each marker corresponds to the growth rate. The viridis colormap automatically assigns colors based on the numeric range of the data. The color bar on the side helps interpret the meaning of each color.
This technique is highly effective for showing data intensity or gradual changes across a variable, commonly used in financial, scientific, and marketing analytics.
Combine Marker Size and Color in a Single Scatter Plot
You can also combine both size and color customizations to represent multiple dimensions in one scatter plot. This is where Matplotlib truly shines in Python.
import matplotlib.pyplot as plt
import numpy as np
# Sample data
sales = np.array([150, 230, 310, 420, 510])
profit = np.array([30, 50, 75, 95, 120])
growth_rate = np.array([5, 10, 15, 20, 25])
customers = np.array([20, 40, 60, 80, 100])
# Combine color and size
plt.scatter(sales, profit, c=growth_rate, s=customers*10, cmap='plasma', alpha=0.8, edgecolors='black')
plt.colorbar(label="Growth Rate (%)")
plt.title("U.S. Sales Data Visualization: Marker Size and Color Customization")
plt.xlabel("Sales (in thousands USD)")
plt.ylabel("Profit (in thousands USD)")
plt.show()Here, the marker size represents the number of customers, while the color represents the growth rate. This visualization provides a multi-dimensional view of your dataset, helping you quickly identify patterns and outliers.
Tips for Effective Scatter Plot Customization in Python
- Use consistent color schemes that are easy on the eyes (e.g., viridis, plasma, coolwarm).
- Add transparency (alpha) to prevent overlapping markers from hiding data.
- Always label your axes, legends, and color bars for clarity.
- Avoid using too many colors or extreme marker sizes; simplicity improves readability.
- When visualizing U.S.-specific data, consider using appropriate units (e.g., USD, miles, or percentages).
When I first started customizing scatter plots in Python, I often overcomplicated things by adding too many visual elements. Over time, I realized that clarity and balance are key. A well-designed scatter plot not only looks professional but also communicates insights clearly.
With these methods, you now have the flexibility to adjust marker size and color in Matplotlib scatter plots to suit your data visualization needs. Whether you’re working on sales analytics, scientific research, or marketing performance tracking, these techniques will help you tell your data story effectively.
You may also like to read:
- Change Linestyle and Color in Matplotlib plot_date() Plots
- Date Format and Convert Dates in Matplotlib plot_date
- Control Date on X-Axis and Xticks in Matplotlib plot_date
- Add Vertical Line at Specific Date in Matplotlib

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.