Use fill_between with the circle’s upper and lower semicircle equations. For a circle centered at (0, 0) with radius r, sample x from -r to r, calculate y = sqrt(r² - x²), then fill between y and -y. Set an equal aspect ratio so the result looks circular.
Shade the complete circle with two semicircle curves
A circle centered at the origin satisfies x² + y² = r². Solving for y gives two boundaries: the upper semicircle, sqrt(r² - x²), and the lower semicircle, -sqrt(r² - x²). Pass both arrays to fill_between:
import numpy as np
import matplotlib.pyplot as plt
r = 2.0
x = np.linspace(-r, r, 400)
y = np.sqrt(r**2 - x**2)
fig, ax = plt.subplots()
ax.fill_between(x, y, -y, color="cornflowerblue", alpha=0.5)
ax.plot(x, y, color="navy")
ax.plot(x, -y, color="navy")
ax.set_aspect("equal", adjustable="box")
plt.show()
The 400 x-values produce a smooth-looking sampled boundary for many ordinary plot sizes. The fill is a polygon constructed between sample points, not a mathematically continuous curve; increase the sample count if the edge looks coarse at your output size.
Why pass both boundaries?
fill_between(x, y1) uses zero as its second boundary by default. With only the positive semicircle, that shades the upper half between the arc and the x-axis. Passing -y explicitly fills the entire disk between its upper and lower edges. The function’s documented signature is fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, *, data=None, **kwargs), and it returns a FillBetweenPolyCollection. See the Matplotlib fill_between API.
#1 Best Overall
Why use an equal aspect ratio?
ax.set_aspect("equal", adjustable="box") makes one x-unit and one y-unit occupy the same display length. Without it, the filled mathematical disk can appear oval if the axes have different scales.
Choose valid x-values and a useful sample density
For the centered circle, use x-values only from -r through r. Outside that interval, r**2 - x**2 is negative, so the real-valued square root needed for the boundary is undefined. A low sample count can make the polygon’s outline visibly angular; a denser array makes the approximation smoother.
Rank #2
Shift the circle away from the origin
For a circle centered at (h, k) with radius r, its x-domain is h-r through h+r, and its two boundaries are k + sqrt(r**2 - (x-h)**2) and k - sqrt(r**2 - (x-h)**2). Use those arrays as the second and third arguments to fill_between:
x = np.linspace(h - r, h + r, 400)
y_upper = k + np.sqrt(r**2 - (x - h)**2)
y_lower = k - np.sqrt(r**2 - (x - h)**2)
ax.fill_between(x, y_upper, y_lower, alpha=0.5)
Use conditional filling only when the region calls for it
The basic circle needs no where mask: the entire interval between the two semicircle arrays is the desired region. A mask is useful when only selected intervals should be shaded. Matplotlib fills an interval only when the mask is true at both adjacent x-samples, so a lone True value does not fill a segment. The Matplotlib “Fill the area between two lines” example illustrates conditional filling.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
When a conditional region ends where two curves cross, set interpolate=True if the fill should reach the calculated intersection rather than stop at a nearby sampled x-node. This is useful for crossing curves; it is unnecessary for the ordinary full-circle fill.
Style the fill and preserve transparency when saving
Use color or facecolor to choose the fill color and alpha to control its opacity. Matplotlib’s basic fill_between example uses a half-transparent fill; linewidth=0 is another option when you want a band without a polygon edge. The basic fill_between example shows this style.
If the alpha transparency matters in an exported figure, save to PNG, PDF, or SVG. Matplotlib’s transparency example notes that PostScript does not support alpha.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When a polygon is a better representation
fill_between is convenient when a shape can be described as upper and lower y-values over x. If you already have the vertices of a closed outline—or the shape cannot be represented cleanly as two y-functions—use pyplot.fill, which fills a polygon from vertex coordinates. See the Matplotlib fill API. For a circle, the two-function method directly expresses the boundary and the region between its arcs.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Quick Recap
Best Value
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.




