- 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
Plotting a probability density function by sample with Matplotlib
To plot a probability density function by sample, we can use numpy for x and y data points.
Steps
- Create x and p data points using numpy.
- Plot x and p data points using plot() method.
- Scale X-axis in a range.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.arange(-100, 100) p = np.exp(-x ** 2) plt.plot(x, p) plt.xlim(-20, 20) plt.show()
Output
- Related Articles
- Plotting power spectral density in Matplotlib
- Plotting a transparent histogram with non-transparent edge in Matplotlib
- Plotting scatter points with clover symbols in Matplotlib
- Interactive plotting with Python Matplotlib via command line
- Plotting with seaborn using the matplotlib object-oriented interface
- How can I make a scatter plot colored by density in Matplotlib?
- How to plot a 3D density map in Python with Matplotlib?
- To study the variation in volume with pressure for a sample of air at constant temperature by plotting graphs between p and v
- How to deal with NaN values while plotting a boxplot using Python Matplotlib?
- Plotting profile histograms in Python Matplotlib
- Plotting dates on the X-axis with Python's Matplotlib
- Plotting a histogram from pre-counted data in Matplotlib
- Plotting a cumulative graph of Python datetimes in Matplotlib
- Plotting regression and residual plot in Matplotlib
- Plotting animated quivers in Python using Matplotlib

Advertisements