- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 the area under a curve in a Seaborn distribution plot?
To fill the area under a curve in a Seaborn distribution plot, we can use distplot() and fill_between() methods.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Create a list of data points.
- Plot a univariate distribution of observations.
- To fill the area under the curve, use fill_between() method.
- Set or retrieve autoscaling margins, x=0 and y=0.
- To display the figure, use show() method.
Example
import seaborn as sns import scipy.stats as stats import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [2.0, 7.5, 9.0, 8.5] ax = sns.distplot(x, fit_kws={"color": "red"}, kde=False, fit=stats.gamma, hist=None, label="label 1") l1 = ax.lines[0] x1 = l1.get_xydata()[:, 0] y1 = l1.get_xydata()[:, 1] ax.fill_between(x1, y1, color="red", alpha=0.3) ax.margins(x=0, y=0) plt.show()
Output
- Related Articles
- 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 fill rainbow color under a curve in Python Matplotlib?
- How to fill color below a curve in Matplotlib?
- How to locate the median in a (Seaborn) KDE plot?
- How to curve text in a polar plot in matplotlib?
- How to plot ROC curve in Python?
- How to save a plot in Seaborn with Python (Matplotlib)?
- How to create a plot of binomial distribution in R?
- How to create a plot of Poisson distribution in R?
- How to create a plot of empirical distribution in R?
- How to plot a dashed line on a Seaborn lineplot in Matplotlib?
- How to create a standard normal distribution curve with 3-sigma limits in R?
- How to fill color above the curve in Matplotlib Program?
- How to show the Logarithmic plot of a cumulative distribution function in Matplotlib?

Advertisements