- 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

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.

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()

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

Advertisements