- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find the area between two curves plotted in Matplotlib

To find the area between two curves plot in matplotlib, we can take the following steps

- Set the figure size and adjust the padding between and around the subplots.
- Create x, c1 and c2 data points using numpy.
- Plot (x, c1) and (x, c2) using plot() methods.
- Fill the area between the two curves, c1 and c2, with grey color and hatch "|", using
**fill_between()**method. - To display the figure, use
**show()**method.

## Example

import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(0, 1, 100) c1 = x ** 2 c2 = x plt.plot(x, c1) plt.plot(x, c2) plt.fill_between(x, c1, c2, color="grey", alpha=0.3, hatch='|') plt.show()

## Output

- Related Questions & Answers
- How to shade the regions between the curves in Matplotlib?
- Shading an area between two points in a Matplotlib plot
- How to color the plotted area of a JavaFX xy-chart?
- Plot curves in fivethirtyeight stylesheet in Matplotlib
- Plot curves to differentiate antialiasing in Matplotlib
- Program to calculate the area between two Concentric Circles in C++?
- How to set label for an already plotted line in Matplotlib?
- Fill between two vertical lines in matplotlib
- Drawing lines between two plots in Matplotlib
- Program to find out the vertical area between two points where no point lies and is the widest in Python
- How can multiple plots be plotted in same figure using matplotlib and Python?
- Program to find total area covered by two rectangles in Python
- Find the minimum distance between two numbers in C++
- Find the compatibility difference between two arrays in C++
- Find the Symmetric difference between two arrays - JavaScript

Advertisements