bundles / scipy 1.17.1 / scipy / stats / _distribution_infrastructure / UnivariateDistribution / plot
function
scipy.stats._distribution_infrastructure:UnivariateDistribution.plot
Signature
def plot ( self , x = x , y = None , * , t = None , ax = None ) Summary
Plot a function of the distribution.
Extended Summary
Convenience function for quick visualization of the distribution underlying the random variable.
Parameters
x, y: str, optionalString indicating the quantities to be used as the abscissa and ordinate (horizontal and vertical coordinates), respectively. Defaults are
'x'(the domain of the random variable) and either'pdf'(the probability density function) (continuous) or'pdf'(the probability density function) (discrete). Valid values are: 'x', 'pdf', 'pmf', 'cdf', 'ccdf', 'icdf', 'iccdf', 'logpdf', 'logpmf', 'logcdf', 'logccdf', 'ilogcdf', 'ilogccdf'.t: 3-tuple of (str, float, float), optionalTuple indicating the limits within which the quantities are plotted. The default is
('cdf', 0.0005, 0.9995)if the domain is infinite, indicating that the central 99.9% of the distribution is to be shown; otherwise, endpoints of the support are used where they are finite. Valid values are: 'x', 'cdf', 'ccdf', 'icdf', 'iccdf', 'logcdf', 'logccdf', 'ilogcdf', 'ilogccdf'.ax: `matplotlib.axes`, optionalAxes on which to generate the plot. If not provided, use the current axes.
Returns
ax: `matplotlib.axes`Axes on which the plot was generated. The plot can be customized by manipulating this object.
Examples
Instantiate a distribution with the desired parameters:import numpy as np import matplotlib.pyplot as plt from scipy import stats X = stats.Normal(mu=1., sigma=2.)✓
ax = X.plot() sample = X.sample(10000)✓
ax.hist(sample, density=True, bins=50, alpha=0.5)
✗plt.show()
✓
X.plot('x', 'logpdf', t=('logcdf', -10, np.log(0.5)))
✗plt.show()
✓
X = stats.Normal(mu=0., sigma=[0.5, 1., 2])
✓X.plot('cdf', 'pdf')
✗plt.show()
✓
Aliases
-
scipy.stats._distribution_infrastructure.UnivariateDistribution.plot