Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to plot prob plots

Educative Answers Team

Probability plots convert the plotting positions into quantiles or probability distribution. Probability plots only check if a data set follows a given distribution. The default being standard-normal (Z) distribution.

To use, import the library:

from scipy import stats

The default implementation of prob plot is:

scipy.stats.probplot(x = None sparms= (), dist= norm, fit:bool = True, plot= None, rvalue:bool = False)


  • x: array-like - The sample from which probplot creates the plot.

  • sparams: tuple - Distribution-specific shape parameters.

  • dist: str or stats.distribution instance - Distribution or distribution function name.

  • fit: bool - Fits a least-squares regression (best-fit) line to the sample data.

  • plot: object - Plots the quantiles and least-squares fit if given. A plot is an object that has to have methods “plot” and “text”. The matplotlib.pyplot module, a Matplotlib Axes object, or a custom object with the same methods can be used.


  • (osm, osr): tuple - It returns a tuple of theoretical quantities and ordered responses.

  • (slope, intercept, r): tuple - Tuple containing the least-square fit, intercept, and the square root of the coefficient of determination. If fit = False and plot = None, nothing is returned.


The following code shows how prob plots can be added in Python. You can change the parameters to see how the output varies.
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np

#generate random values

#draw a distribution
x = stats.t.rvs(25, size = 100)

#plot the graph
res = stats.probplot(x, plot=plt)

#show the graph


Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring