A Portland bike shop owner asked me for a Q1 2026 revenue pie that matches her navy slide deck instead of sitting on a white box.
The fix for a Matplotlib pie chart background color is facecolor on the figure. The axes color only shows after ax.set_frame_on(True), because pie() hides it.
fig, ax = plt.subplots(facecolor="#14213D")
ax.pie(revenue, labels=labels)
Here’s what we’re building:

In this tutorial, I’ll build it one change at a time, test the saved PNG, then cover transparent and donut versions. I ran everything on Matplotlib 3.11.2 and Python 3.12.5.
Before You Start: The Q1 2026 Bike Shop Revenue Data
New to pies? You can skim my Matplotlib pie chart tutorial first.
Every step imports shop.py, made-up Portland bike shop revenue:
| Name | Type | Notes |
|---|---|---|
| labels | list of str | Five sales categories |
| revenue | list of float | Q1 2026 revenue in USD |
# Portland, OR bike shop revenue, Q1 2026 (USD)
labels = ["Bikes", "E-Bikes", "Repairs", "Parts", "Apparel"]
revenue = [48250.00, 61900.00, 18475.50, 22310.25, 9864.75]
if __name__ == "__main__":
for name, amount in zip(labels, revenue):
print(f"{name:<8} ${amount:>10,.2f}")
print(f"{'Total':<8} ${sum(revenue):>10,.2f}")
Output:
Bikes $ 48,250.00
E-Bikes $ 61,900.00
Repairs $ 18,475.50
Parts $ 22,310.25
Apparel $ 9,864.75
Total $160,800.50

Step 1: Draw the Pie Chart with the Default Background
First, a plain pie to compare against. The autopct string prints percentages, as my autopct formatting guide explains.
import matplotlib.pyplot as plt
from matplotlib.colors import to_hex
from shop import labels, revenue
fig, ax = plt.subplots(figsize=(6, 5))
ax.pie(revenue, labels=labels, autopct="%1.1f%%", startangle=90)
print("Figure color:", to_hex(fig.get_facecolor()))
print("Axes frame drawn:", ax.get_frame_on())
plt.show()
Output:
Figure color: #ffffff
Axes frame drawn: False

Checkpoint: the figure color is #ffffff and the axes frame reports False. That second value matters in Step 3.
Step 2: Set the Figure Background Color with facecolor
The figure is the whole canvas, so its color fills everything around the pie. Pass facecolor to plt.subplots():
import matplotlib.pyplot as plt
from matplotlib.colors import to_hex
from shop import labels, revenue
BG = "#14213D" # navy brand color
fig, ax = plt.subplots(figsize=(6, 5), facecolor=BG)
ax.pie(revenue, labels=labels, autopct="%1.1f%%", startangle=90)
print("Figure color:", to_hex(fig.get_facecolor()))
plt.show()
Output:
Figure color: #14213d

Checkpoint: the figure prints #14213d, and an existing figure gets the same result from fig.set_facecolor(BG). My Matplotlib background color guide covers other plot types.
Step 3: Color the Axes Box Behind the Pie
A lighter panel behind the pie is the axes patch. I expected ax.set_facecolor() to work alone, but nothing showed until I turned the frame on:
import matplotlib.pyplot as plt
from shop import labels, revenue
fig, ax = plt.subplots(figsize=(6, 5), facecolor="#14213D")
ax.pie(revenue, labels=labels, autopct="%1.1f%%", startangle=90)
ax.set_facecolor("#E9EEF6")
print("Frame on after pie():", ax.get_frame_on())
ax.set_frame_on(True) # pie() hides the frame and its patch
for spine in ax.spines.values():
spine.set_visible(False)
print("Frame on now:", ax.get_frame_on())
plt.show()
Output:
Frame on after pie(): False
Frame on now: True

Checkpoint: the frame reads False right after pie() and True after set_frame_on(True). Hiding the spines removes the black border. See inner and outer background colors for the same split on line charts.
Step 4: Style the Wedges and Labels for a Dark Background
Same revenue data, now readable for you on navy. I’ll drop the axes box and keep one color.
import matplotlib.pyplot as plt
from matplotlib.colors import to_hex
from shop import labels, revenue
BG = "#14213D"
colors = ["#FCA311", "#4EA8DE", "#90BE6D", "#E5E5E5", "#F9844A"]
fig, ax = plt.subplots(figsize=(6, 5), facecolor=BG)
wedges, texts, pcts = ax.pie(
revenue, labels=labels, colors=colors, autopct="%1.1f%%",
startangle=90, pctdistance=0.72,
wedgeprops={"edgecolor": BG, "linewidth": 3},
textprops={"color": "white", "fontsize": 11})
for pct in pcts:
pct.set_color(BG) # dark numbers on light wedges
print(len(wedges), "wedges, edge", to_hex(wedges[0].get_edgecolor()))
print("Label color:", texts[0].get_color())
plt.show()
Output:
5 wedges, edge #14213d
Label color: white

Checkpoint: all five wedges report a #14213d edge and the labels are white. textprops styles every label first, then the loop flips the percentages to navy. For a hatched look, try pie chart hatch patterns.
Test the Pie Chart Background with savefig
Does the color survive export? The finished script adds a title and saves before plt.show(), as my save a Matplotlib chart as PNG tutorial explains.
import matplotlib.pyplot as plt
from shop import labels, revenue
BG = "#14213D"
colors = ["#FCA311", "#4EA8DE", "#90BE6D", "#E5E5E5", "#F9844A"]
fig, ax = plt.subplots(figsize=(6, 5), facecolor=BG)
_, _, pcts = ax.pie(
revenue, labels=labels, colors=colors, autopct="%1.1f%%",
startangle=90, pctdistance=0.72,
wedgeprops={"edgecolor": BG, "linewidth": 3},
textprops={"color": "white", "fontsize": 11})
for pct in pcts:
pct.set_color(BG)
ax.set_title(f"Q1 2026 Revenue: ${sum(revenue):,.2f}",
color="white", fontsize=15, fontweight="bold")
fig.savefig("q1_revenue_pie.png", dpi=100)
print("Saved q1_revenue_pie.png")
plt.show()
Output:
Saved q1_revenue_pie.png
Next, you check the pixels. This saves a solid and a transparent copy and reads each top-left corner:
import matplotlib
matplotlib.use("Agg") # no window, just files
import matplotlib.pyplot as plt
from matplotlib.colors import to_hex
from shop import labels, revenue
BG = "#14213D"
fig, ax = plt.subplots(figsize=(6, 5), facecolor=BG)
ax.pie(revenue, labels=labels, startangle=90,
wedgeprops={"edgecolor": BG, "linewidth": 3},
textprops={"color": "white"})
fig.savefig("pie_solid.png")
fig.savefig("pie_clear.png", transparent=True)
for name in ("pie_solid.png", "pie_clear.png"):
px = plt.imread(name)[5, 5] # top-left corner pixel
print(f"{name}: corner {to_hex(px)}, alpha {px[3]:.1f}")
Output:
pie_solid.png: corner #14213d, alpha 1.0
pie_clear.png: corner #ffffff, alpha 0.0

The solid PNG keeps navy because savefig.facecolor defaults to "auto", which copies the figure color.
Make the Pie Chart Background Transparent
For a slide or web page with its own background, add transparent=True to savefig(), as in pie_clear.png above. The corner’s alpha drops to 0.0, so whatever sits behind the image shows through. My transparent PNG guide has more export options.
Show the Background Through a Donut Hole
Same data as a donut: wedgeprops={"width": 0.38} cuts the hole, and the navy figure shows through it. More ring options are in my Matplotlib donut chart tutorial.
import matplotlib.pyplot as plt
from shop import labels, revenue
BG = "#14213D"
colors = ["#FCA311", "#4EA8DE", "#90BE6D", "#E5E5E5", "#F9844A"]
fig, ax = plt.subplots(figsize=(6, 5), facecolor=BG)
ax.pie(revenue, colors=colors, startangle=90,
wedgeprops={"width": 0.38, "edgecolor": BG,
"linewidth": 3})
ax.text(0, 0, f"${sum(revenue):,.2f}\nQ1 2026", ha="center",
va="center", color="white", fontsize=15,
fontweight="bold")
fig.legend(labels, loc="lower center", ncols=5, frameon=False,
labelcolor="white")
print("Hole shows the figure color behind the ring")
plt.show()
Output:
Hole shows the figure color behind the ring

Why Is My Pie Chart Background Still White? (Troubleshooting)
ax.set_facecolor()does nothing:pie()turns the frame off; addax.set_frame_on(True).- Saved PNG is white: something passed
facecolor="white"tosavefig(); drop it or passfig.get_facecolor(). - Labels vanish on dark colors: set
textprops={"color": "white"}. - Blank saved file: call
savefig()beforeplt.show().
Where to Take It Next
Point out the biggest slice with labels and arrows from my pie chart annotation tutorial.
Then size the title for the slide using pie chart title font size.
A few related styling guides I’d open next:
- Transparent plot backgrounds and legend styling
- Change the Matplotlib legend font size
- Matplotlib bar chart title font size
- Color subplot backgrounds by value
Frequently asked questions
How do I change the background color of a pie chart in Matplotlib?
Pass facecolor when you create the figure, for example plt.subplots(facecolor="#14213D"), or call fig.set_facecolor().
Why doesn’t ax.set_facecolor() change my pie chart?
ax.pie() switches the Axes frame off, which hides its background patch. Call ax.set_frame_on(True) after the pie.
How do I save a pie chart with a transparent background?
Use fig.savefig("pie.png", transparent=True). The figure and axes backgrounds are saved fully transparent.
Does savefig keep my pie chart background color?
Yes. savefig.facecolor defaults to "auto", which uses the figure’s own color.
How do I change the color inside a donut hole?
The hole shows the figure color, so set the figure facecolor, or draw a Circle with its own color in the center.
Where is facecolor documented?

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn