Loading...

vastorbit.VastFrame.density

VastFrame.density(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, nbins: int = 100, chart: PlottingBase | TableSample | Axes | mFigure | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Figure

Draws the VastColumns Density Plot using histogram approximation.

Parameters:
  • columns (SQLColumns, optional) – List of the VastColumns names. If empty, all numerical VastColumns are selected.

  • nbins (int, optional) – Number of bins for histogram approximation. Higher values give smoother density estimates.

  • chart (PlottingObject, optional) – The chart object to plot on.

  • **style_kwargs – Any optional parameter to pass to the plotting functions.

Returns:

Plotting Object.

Return type:

obj

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 vastorbit.

import vastorbit as vo

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 = vo.VastFrame(
    {
        "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

VastFrame.hist() : Histogram.
VastFrame.range_plot() : Range Plot.
VastColumn.density() : Density Plot.