Skip to content

plot_distribution


method plot_distribution(columns=0, distributions=None, show=None, title=None, figsize=None, filename=None, display=True, **kwargs) [source]

Plot column distributions. Additionally, it is possible to plot any of scipy.stats probability distributions fitted to the column. Missing values are ignored.

Parameters:

columns: int, str, slice or sequence, optional (default=0)
Slice, names or indices of the columns to plot. It is only possible to plot one categorical column. If more than just the one categorical column is selected, all categorical columns are ignored.

distributions: str, sequence or None, optional (default=None)
Names of the scipy.stats distributions to fit to the column. If None, no distribution is fitted. Only for numerical columns.

show: int or None, optional (default=None)
Number of classes (ordered by number of occurrences) to show in the plot. None to show all. Only for categorical columns.

title: str or None, optional (default=None)
Plot's title. If None, the title is left empty.

figsize: tuple, optional (default=None)
Figure's size, format as (x, y). If None, adapts size to the plot's type.

filename: str or None, optional (default=None)
Name of the file. Use "auto" for automatic naming. If None, the figure is not saved.

display: bool or None, optional (default=True)
Whether to render the plot. If None, it returns the matplotlib figure.

**kwargs
Additional keyword arguments for seaborn's histplot.

Returns: matplotlib.figure.Figure
Plot object. Only returned if display=None.

Tip

Use atom's distribution method to check which distribution fits the column best.


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.plot_distribution(columns=[1, 2])  # With numerical columns
plot_distribution_1
# With fitted distributions
atom.plot_distribution(columns="mean radius", distributions=["norm", "triang"])
plot_distribution_2
# With categorical columns
atom.plot_distribution(columns="Location", show=11)
plot_distribution_3
Back to top