Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk2 min

How to Use Matplotlib fill_between With or Without an Edge

Use linewidth=0 to hide a Matplotlib fill_between outline, or set edgecolor and linewidth to style it.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use linewidth=0 to remove the visible outline around a fill_between area. To show an outline, set edgecolor and adjust its thickness with linewidth.

Remove the outline from a filled area

fill_between creates a polygon collection between two curves. Set its line width to zero to suppress the collection’s outline:

ax.fill_between(x, y1, y2, color="C0", alpha=0.3, linewidth=0)

This is the approach used in Matplotlib’s official fill-between example. The fill color and transparency remain controlled by color and alpha.

Draw an edge around the fill

Set edgecolor to choose an outline color, then set linewidth to control its thickness. The shorter aliases are ec and lw.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ax.fill_between(
    x, y1, y2,
    facecolor="tab:blue",
    edgecolor="navy",
    linewidth=1,
)

To make the edge the same color as the filled area, use edgecolor="face":

ax.fill_between(x, y1, y2, facecolor="tab:blue", edgecolor="face")

These styling properties are passed to the FillBetweenPolyCollection returned by the call. The Axes.fill_between API reference documents the supported collection properties, including edgecolor, facecolor and linewidth.

Keep the fill edge separate from plotted curves

The fill’s polygon outline and a curve drawn with plot are separate plot elements. Setting linewidth=0 on fill_between removes the collection outline, but does not hide a line drawn separately:

ax.fill_between(x, y1, y2, color="tab:blue", alpha=0.25, linewidth=0)
ax.plot(x, y1, color="black", linewidth=1)

If a boundary looks doubled, check whether both the fill collection and a separately plotted curve are drawing along it. Adjust the fill edge and the line artist independently.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Control where and how the area is filled

The call fills between the curves through (x, y1) and (x, y2); if y2 is omitted, it defaults to zero. Use these additional arguments when the filled region needs to follow a condition or stepwise data:

  • where takes a Boolean mask. An interval from x[i] to x[i+1] is filled only when both corresponding mask values are true. A single true value between false values does not create a filled interval.
  • For a condition such as y1 > y2, the curves can cross between sampled points. With the default interpolate=False, the fill is limited to sample positions. Set interpolate=True to estimate the crossing and extend the fill to that intersection.
  • Set step to 'pre', 'post' or 'mid' when the fill should represent stepwise values.

See the API reference for argument details. It identifies Matplotlib 3.11.2; consult the documentation matching the version used by your project if its behavior or accepted properties differ.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.