Histogram.plot (function)
def plot(self, size=100000.0, unit=None, wrap_at=None, seed=None, samples=None, plot_sample=True, plot_sample_kwargs={'color': 'gray'}, plot_pdf=True, plot_pdf_kwargs={'color': 'red'}, plot_cdf=False, plot_cdf_kwargs={'color': 'green'}, plot_gaussian=False, plot_gaussian_kwargs={'color': 'blue'}, plot_uncertainties=True, plot_uncertainties_kwargs={'color': 'black', 'linestyle': 'dashed'}, label=None, xlabel=None, show=False, **kwargs)
Plot both the analytic distribution function as well as a sampled histogram from the distribution. Requires matplotlib to be installed.
See also:
size
(int, optional, default=1e5): number of points to sample for the histogram. See also Histogram.sample. Will be ignored ifsamples
is provided.unit
(astropy.unit, optional, default=None): units to use along the x-axis. Astropy must be installed. Ifsamples
is provided, the passed values will be assumed to be in the correct units.wrap_at
(float, None, or False, optional, default=None): value to use for wrapping. See Histogram.wrap. If not provided or None, will use the value from Histogram.wrap_at. Note: wrapping is computed before changing units, sowrap_at
must be provided according to Histogram.unit notunit
. Will be ignored ifsamples
is provided.seed
(int, optional): seed to use when sampling. See also Histogram.sample. Will be ignored ifsamples
is provided.samples
(array, optional, default=None): plot specific sampled values instead of calling Histogram.sample internally. Will overridesize
.plot_sample
(bool, optional, default=True): whether to plot the histogram from sampling. See also Histogram.plot_sample.plot_sample_kwargs
(dict, optional, default={'color': 'gray'}): keyword arguments to send to Histogram.plot_sample.plot_pdf
(bool, optional, default=True): whether to plot the analytic form of the underlying distribution, if applicable. See also Histogram.plot_pdf.plot_pdf_kwargs
(dict, optional, default={'color': 'red'}): keyword arguments to send to Histogram.plot_pdf.plot_cdf
(bool, optional, default=True): whether to plot the analytic form of the cdf, if applicable. See also Histogram.plot_cdf.plot_cdf_kwargs
(dict, optional, default={'color': 'green'}): keyword arguments to send to Histogram.plot_cdf.plot_gaussian
(bool, optional, default=False): whether to plot a guassian distribution fit to the sample. Only supported for distributions that have Histogram.to_gaussian methods.plot_gaussian_kwargs
(dict, optional, default={'color': 'blue'}): keyword arguments to send to Histogram.plot_gaussian.plot_uncertainties
(bool or int, optional, default=True): whether to plot uncertainties (as vertical lines) and include the representation of the uncertainties in the plot title. If an integer, will plot at thatsigma
. If True, will default tosigma=1
. See Histogram.uncertainties.plot_uncertainties_kwargs
(dict, optional, default={'color': 'black', 'linestyle': 'dashed'}): keyword arguments to send to Histogram.plot_uncertainties.label
(string, optional, default=None): override the label on the x-axis. If not provided or None, will use Histogram.label. Will only be used ifshow=True
. Unit will automatically be appended. Will be ignored ifxlabel
is provided.xlabel
(string, optional, default=None): override the label on the x-axis without appending the unit. Will overridelabel
.show
(bool, optional, default=True): whether to show the resulting matplotlib figure.**kwargs
: all keyword arguments (except forbins
) will be passed on to Histogram.plot_pdf and Histogram.plot_gaussian and all keyword arguments will be passed on to Histogram.plot_sample. Keyword arguments defined inplot_sample_kwargs
,plot_pdf_kwargs
, andplot_gaussian_kwargs
will override the values sent inkwargs
.
- tuple: the return values from Histogram.plot_sample (or None if
plot_sample=False
), Histogram.plot_pdf (or None ifplot_pdf=False
), Histogram.plot_cdf (or None ifplot_cdf=False
), Gaussian.plot_pdf (or None ifplot_gaussian=False
), and Histogram.plot_uncertainties (or None ifplot_uncertainties=False
).
- ImportError: if matplotlib dependency is not met.