- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to fill color above the curve in Matplotlib Program?
To fill color above the curve, we can take the following steps −
Steps
Initialize the variable n. Initialize x and y data points using numpy.
Create a figure and a set of subplots, fig and ax.
Plot the curve using plot() method.
Using fill_between() method, fill the area between two curves, with 1 value.
To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True n = 256 X = np.linspace(-np.pi, np.pi, n, endpoint=True) Y = np.sin(2 * X) fig, ax = plt.subplots() ax.plot(X, Y, color='blue', alpha=1.00) ax.fill_between(X, Y, 1, color='blue', alpha=.1) plt.show()
Output
- Related Articles
- How to fill color below a curve in Matplotlib?
- How to fill rainbow color under a curve in Python Matplotlib?
- How to fill the area under a step curve using pyplot? (Matplotlib)
- Fill the area under a curve in Matplotlib python on log scale
- How to change the curve using radiobuttons in Matplotlib?
- How to animate a sine curve in Matplotlib?
- How to add a cursor to a curve in Matplotlib?
- How to curve text in a polar plot in matplotlib?
- How to remove a specific line or curve in Matplotlib?
- Program to fill with color using floodfill operation in Python
- How to fill the area under a curve in a Seaborn distribution plot?
- How to change axes background color in Matplotlib?
- How to drop fill color to change the image color using HTML and CSS?
- How to plot sine curve on polar axes using Matplotlib?
- How to draw a precision-recall curve with interpolation in Python Matplotlib?

Advertisements