scipy.stats._result_classes.FitResult.plot#

FitResult.plot(ax=None, *, plot_type='hist')[source]#

Visually compare the data against the fitted distribution.

Available only if matplotlib is installed.

Parameters:
axmatplotlib.axes.Axes

Axes object to draw the plot onto, otherwise uses the current Axes.

plot_type{“hist”, “qq”, “pp”, “cdf”}

Type of plot to draw. Options include:

  • “hist”: Superposes the PDF/PMF of the fitted distribution over a normalized histogram of the data.

  • “qq”: Scatter plot of theoretical quantiles against the empirical quantiles. Specifically, the x-coordinates are the values of the fitted distribution PPF evaluated at the percentiles (np.arange(1, n) - 0.5)/n, where n is the number of data points, and the y-coordinates are the sorted data points.

  • “pp”: Scatter plot of theoretical percentiles against the observed percentiles. Specifically, the x-coordinates are the percentiles (np.arange(1, n) - 0.5)/n, where n is the number of data points, and the y-coordinates are the values of the fitted distribution CDF evaluated at the sorted data points.

  • “cdf”: Superposes the CDF of the fitted distribution over the empirical CDF. Specifically, the x-coordinates of the empirical CDF are the sorted data points, and the y-coordinates are the percentiles (np.arange(1, n) - 0.5)/n, where n is the number of data points.

Returns:
axmatplotlib.axes.Axes

The matplotlib Axes object on which the plot was drawn.