Loading...

vastorbit.VastColumn.bar

VastColumn.bar(method: Literal[None, 'density', 'count', 'avg', 'min', 'max', 'sum'] | str = 'density', of: str | None = None, max_cardinality: int = 6, nbins: int = 0, h: Annotated[int | float | Decimal, 'Python Numbers'] = 0, categorical: bool = True, bargap: float = 0.06, categoryorder: Literal['trace', 'category ascending', 'category descending', 'total ascending', 'total descending'] = 'trace', chart: PlottingBase | TableSample | Axes | mFigure | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Figure

Draws the bar chart of the VastColumn based on an aggregation.

Parameters:
  • 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.

    It can also be a cutomized aggregation (ex: AVG(column1) + 5).

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

  • max_cardinality (int, optional) – Maximum number of distinct VastColumns elements to be used as categorical. For these elements, no h is picked or computed.

  • nbins (int, optional) – Number of bins. If empty, an optimized number of bins is computed.

  • h (PythonNumber, optional) – Interval width of the bar. If empty, an optimized h is computed.

  • categorical (bool, optional) – If set to False and the VastColumn is numerical, the parmater ‘max_cardinality’ is ignored and the bar chart is represented as a histogram.

  • bargap (float, optional) – A float between (0, 1] that represents the proportion taken out of each bar to render the chart. This proportion creates gaps between each bar. The bigger the value, the bigger the gap.

  • categoryorder (str, optional) –

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

    • trace (no transformation)

    • category ascending

    • category descending

    • total ascending

    • total 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'],
    }
)

Now we are ready to draw the plot:

data["grade"].bar()

See also

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