Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: What is the purpose of the `plt.fill_between()` function in Matplotlib?
Answer: `plt.fill_between()` is used to fill the area between two horizontal curves on the plot.

Example:

x = [1, 2, 3, 4]
y1 = [10, 20, 25, 30]
y2 = [5, 15, 20, 25]
plt.fill_between(x, y1, y2, color='gray', alpha=0.5)
plt.show()
Is it helpful? Yes No

Most helpful rated by users:

©2026 WithoutBook