As a Python developer, I have found the fill_between function to be incredibly useful for highlighting areas between curves in data visualization. Whether you’re plotting financial trends, weather data, or any other time series, knowing how to control the edges of the filled area can make your charts clearer and more professional.
In this article, I’ll share practical methods to use Matplotlib’s fill_between function both with edges and without edges. I’ll walk you through two ways to create shaded regions with visible edges and two ways to fill areas without any borders. This hands-on guide will help you master these techniques and apply them effectively in your Python projects.
Matplotlib fill_between with Edge in Python
When you want your filled area to stand out clearly, adding edges (or borders) to the filled region is essential. Edges help define the boundaries and make the visualization more readable, especially when multiple filled areas overlap.
Method 1: Use edgecolor Parameter
Matplotlib’s fill_between supports an edgecolor parameter, which allows you to specify the color of the boundary line around the filled area. This is the simplest way to add a visible edge.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 500)
y1 = np.sin(x)
y2 = np.sin(x) + 0.5
plt.figure(figsize=(10, 6))
plt.plot(x, y1, label='sin(x)')
plt.plot(x, y2, label='sin(x) + 0.5')
# Fill between with edgecolor
plt.fill_between(x, y1, y2, color='skyblue', edgecolor='navy', linewidth=2, label='Filled Area with Edge')
plt.title('Matplotlib fill_between with Edge (Using edgecolor)')
plt.legend()
plt.show()In this example, I set the edgecolor to ‘navy’ and increased the linewidth to make the edge more prominent. This technique works well when you want to emphasize the boundary of the filled region.
I executed the above example code and added the screenshot below.

Method 2: Use linestyle and linewidth for Edge Customization
Sometimes, you want more control over the edge style, such as dashed or dotted borders. You can combine edgecolor with linestyle and linewidth to customize the edge appearance.
plt.figure(figsize=(10, 6))
plt.plot(x, y1, label='sin(x)')
plt.plot(x, y2, label='sin(x) + 0.5')
plt.fill_between(x, y1, y2, color='lightcoral', edgecolor='darkred', linewidth=2, linestyle='--', label='Dashed Edge')
plt.title('Matplotlib fill_between with Edge (Custom Linestyle)')
plt.legend()
plt.show()I executed the above example code and added the screenshot below.

Here, I used a dashed line (linestyle=’–‘) for the edge, which can be helpful to differentiate multiple filled areas or to match a specific design style.
Use Matplotlib fill_between with No Edge in Python
In some cases, you might want a clean filled area without any distracting edges, especially when the focus is on the shaded region itself or when layering multiple fills.
Method 1: Set edgecolor to None
The easiest way to remove edges is to set the edgecolor parameter to None. This completely removes the border from the filled area.
plt.figure(figsize=(10, 6))
plt.plot(x, y1, label='sin(x)')
plt.plot(x, y2, label='sin(x) + 0.5')
plt.fill_between(x, y1, y2, color='mediumseagreen', edgecolor=None, label='Filled Area without Edge')
plt.title('Matplotlib fill_between without Edge (edgecolor=None)')
plt.legend()
plt.show()I executed the above example code and added the screenshot below.

This method produces a smooth filled region with no visible edges, giving a minimalist and clean look to your plot.
Method 2: Use linewidth=0
Alternatively, you can remove the edge by setting the linewidth parameter to zero. This effectively hides the border without needing to specify edgecolor.
plt.figure(figsize=(10, 6))
plt.plot(x, y1, label='sin(x)')
plt.plot(x, y2, label='sin(x) + 0.5')
plt.fill_between(x, y1, y2, color='orchid', linewidth=0, label='No Edge with linewidth=0')
plt.title('Matplotlib fill_between without Edge (linewidth=0)')
plt.legend()
plt.show()I executed the above example code and added the screenshot below.

This approach is useful if you want to keep the default edge color but simply hide the border by removing its thickness.
Using these methods, you can easily control whether your filled areas in Matplotlib have visible edges or not. In my experience, choosing between edges and no edges depends on the story you want your data visualization to tell.
Adding edges can improve clarity when comparing multiple datasets, while having no edges can make the visualization look cleaner and less cluttered. Both approaches are valuable tools in your Python visualization toolkit.
I encourage you to experiment with these methods on your own data. Whether you’re working on financial trends in New York City or weather patterns across California, mastering fill_between with edge control will elevate your Matplotlib skills and help you create professional, impactful charts.
Happy plotting!
Related articles you might like:
- Matplotlib Tight_Layout for Python Subplots
- How to Use tight_layout and bbox_inches in Matplotlib
- Matplotlib Scatter Plots with Tight_Layout in Python
- Matplotlib fill_between Hatch Color and Facecolor

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.