

- 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
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 Questions & Answers
- Plotting power spectral density in Matplotlib
- How can I make a scatter plot colored by density in Matplotlib?
- How to plot a 3D density map in Python with Matplotlib?
- Plotting a transparent histogram with non-transparent edge in Matplotlib
- Interactive plotting with Python Matplotlib via command line
- Plotting scatter points with clover symbols in Matplotlib
- How to create a sample or samples using probability distribution in R?
- How to generate a probability density distribution from a set of observations in R?
- Plotting with seaborn using the matplotlib object-oriented interface
- How to plot a density map in Python Matplotlib?
- Plotting profile histograms in Python Matplotlib
- How to deal with NaN values while plotting a boxplot using Python Matplotlib?
- Plotting a histogram from pre-counted data in Matplotlib
- Plotting a cumulative graph of Python datetimes in Matplotlib
- How to decrease the hatch density in Matplotlib?
Advertisements