Loading...

verticapy.vDataFrame.density#

vDataFrame.density(columns: str | list[str] | None = None, bandwidth: float = 1.0, kernel: Literal['gaussian', 'logistic', 'sigmoid', 'silverman'] = 'gaussian', nbins: int = 50, xlim: list[tuple[float, float]] = None, chart: PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure#

Draws the vDataColumns Density Plot.

Parameters#

columns: SQLColumns, optional

List of the vDataColumns names. If empty, all numerical vDataColumns are selected.

bandwidth: float, optional

The bandwidth of the kernel.

kernel: str, optional

The method used for the plot.

  • gaussian:

    Gaussian Kernel.

  • logistic:

    Logistic Kernel.

  • sigmoid:

    Sigmoid Kernel.

  • silverman:

    Silverman Kernel.

nbins: int, optional

Maximum number of points used to evaluate the approximate density function. Increasing this parameter increases the precision but also increases the time of the learning and the scoring phases.

xlim: list of tuple, optional

Set the x limits of the current axes.

chart: PlottingObject, optional

The chart object to plot on.

**style_kwargs

Any optional parameter to pass to the plotting functions.

Returns#

obj

Plotting Object.

Examples#

Note

The below example is a very basic one. For other more detailed examples and customization options, please see Density

Let’s begin by importing VerticaPy.

import verticapy as vp

Let’s also import numpy to create a dataset.

import numpy as np

We can create a variable N to fix the size:

N = 50

Let’s generate a dataset using the following data.

data = vp.vDataFrame(
    {
        "score1": np.random.normal(5, 1, N),
        "score2": np.random.normal(8, 1.5, N),
        "score3": np.random.normal(10, 2, N),
    }
)

Below are examples of two types of density plots:

  • Single

  • Multi

data.density(["score1"])
data.density(columns = ["score1", "score2"])

See also

vDataFrame.hist() : Histogram.
vDataFrame.range_plot() : Range Plot.
vDataColumn.density() : Density Plot.