Skip to main content
`Ctrl`+`K`
scipy.stats.Uniform.

# plot

Uniform.plot(x='x', y='pdf', *, t=('cdf', 0.0005, 0.9995), ax=None)

  Plot a function of the distribution.

  Convenience function for quick visualization of the distribution underlying the random variable.

  Parameters:
    x, y str, optional

      String 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 `'pdf'` (the probability density function). Valid values are: ‘x’, ‘pdf’, ‘cdf’, ‘ccdf’, ‘icdf’, ‘iccdf’, ‘logpdf’, ‘logcdf’, ‘logccdf’, ‘ilogcdf’, ‘ilogccdf’.

    t 3-tuple of (str, float, float), optional

      Tuple indicating the limits within which the quantities are plotted. Default is `('cdf', 0.001, 0.999)` indicating that the central 99.9% of the distribution is to be shown. Valid values are: ‘x’, ‘cdf’, ‘ccdf’, ‘icdf’, ‘iccdf’, ‘logcdf’, ‘logccdf’, ‘ilogcdf’, ‘ilogccdf’.

    ax `matplotlib.axes`, optional

      Axes 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.)

  Plot the PDF over the central 99.9% of the distribution. Compare against a histogram of a random sample.

      >>> ax = X.plot()
      >>> sample = X.sample(10000)
      >>> ax.hist(sample, density=True, bins=50, alpha=0.5)
      >>> plt.show()

  Plot `logpdf(x)` as a function of `x` in the left tail, where the log of the CDF is between -10 and `np.log(0.5)`.

      >>> X.plot('x', 'logpdf', t=('logcdf', -10, np.log(0.5)))
      >>> plt.show()

  Plot the PDF of the normal distribution as a function of the CDF for various values of the scale parameter.

      >>> X = stats.Normal(mu=0., sigma=[0.5, 1., 2])
      >>> X.plot('cdf', 'pdf')
      >>> plt.show()