Loading...

vastorbit.VastFrame.bar

VastFrame.bar(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'], method: Literal[None, 'density', 'count', 'avg', 'min', 'max', 'sum'] | str = 'density', of: str | None = None, max_cardinality: tuple[int, int] = (6, 6), h: tuple[Annotated[int | float | Decimal, 'Python Numbers'], Annotated[int | float | Decimal, 'Python Numbers']] = (None, None), kind: Literal['auto', 'drilldown', 'stacked'] = 'auto', categoryorder: Literal['trace', 'category ascending', 'category descending', 'total ascending', 'total descending', 'min ascending', 'min descending', 'max ascending', 'max descending', 'sum ascending', 'sum descending', 'mean ascending', 'mean descending', 'median ascending', 'median descending'] = 'trace', chart: PlottingBase | TableSample | Axes | mFigure | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Figure

Draws the bar chart of the input VastColumns based on an aggregation.

Parameters:
  • columns (SQLColumns) – list of the VastColumns names.

  • method (str, optional) –

    The method used to aggregate the data.

    • count:

      Number of elements.

    • density:

      Percentage of the distribution.

    • mean:

      Average of the VastColumns of.

    • min:

      Minimum of the VastColumns of.

    • max:

      Maximum of the VastColumns of.

    • sum:

      Sum of the VastColumns of.

    • q%:

      q Quantile of the VastColumns of (ex: 50% to get the median).

    • None:

      No Aggregations. Parameter of must be empty, otherwise it is ignored.

    It can also be a cutomized aggregation, for example: AVG(column1) + 5

  • of (str, optional) – The VastColumns used to compute the aggregation.

  • max_cardinality (tuple, optional) –

    Maximum number of distinct elements for VastColumns 1 and 2 to be used as categorical. For these elements, no h is picked or computed.

    Important

    This parameter is only used for categorical data types. For numerics use h to discretize them first

  • h (tuple, optional) –

    Interval width of the VastColumns 1 and 2 bars.

    Important

    Only valid if the VastColumns are numerical. Optimized h will be computed if the parameter is empty or invalid.

  • kind (str, optional) –

    The BarChart Type.

    • auto:

      Regular Bar Chart based on 1 or 2 VastColumns.

    • drilldown:

      Drilldown Bar Chart.

    • pyramid:

      Pyramid Density Bar Chart. Only works if one of the two VastColumns is binary and the method='density'.

    • stacked:

      Stacked Bar Chart based on 2 VastColumns.

    • fully_stacked:

      Fully Stacked Bar Chart based on 2 VastColumns.

  • categoryorder (str, optional) –

    How to sort the bars. One of the following options:

    • trace (no transformation)

    • category ascending

    • category descending

    • total ascending

    • total descending

    • min ascending

    • min descending

    • max ascending

    • max descending

    • sum ascending

    • sum descending

    • mean ascending

    • mean descending

    • median ascending

    • median descending

  • 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 Bar Chart

Let’s begin by importing vastorbit.

import vastorbit as vo

Let’s also import numpy to create a dataset.

import numpy as np

Let’s generate a dataset using the following data.

data = vo.VastFrame(
    {
        "gender": ['M', 'M', 'M', 'F', 'F', 'F', 'F'],
        "grade": ['A','B','C','A','B','B', 'B'],
    }
)

Below are examples of two types of bar plots:

  • 1D

  • 2D

data.bar(["grade"])
data.bar(columns = ["grade", "gender"])

See also

VastFrame.barh() : Horizontal Bar Chart.
VastColumn.bar() : Bar Chart.
VastColumn.barh() : Horizontal Bar Chart.