vastorbit.VastFrame.barh¶
- VastFrame.barh(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', 'fully_stacked', 'stacked', 'fully', 'fully stacked', 'pyramid', 'density'] = '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 horizontal bar chart of the input
VastColumnsbased on an aggregation.- Parameters:
columns (SQLColumns) –
listof theVastColumnsnames.method (str, optional) –
The method used to aggregate the data.
- count:
Number of elements.
- density:
Percentage of the distribution.
- mean:
Average of the
VastColumnsof.
- min:
Minimum of the
VastColumnsof.
- max:
Maximum of the
VastColumnsof.
- sum:
Sum of the
VastColumnsof.
- q%:
q Quantile of the
VastColumnsof(ex: 50% to get the median).
- None:
No Aggregations. Parameter
ofmust be empty, otherwise it is ignored.
It can also be a cutomized aggregation, for example:
AVG(column1) + 5of (str, optional) – The
VastColumnsused to compute the aggregation.max_cardinality (tuple, optional) –
Maximum number of distinct elements for
VastColumns1 and 2 to be used as categorical. For these elements, nohis picked or computed.Important
This parameter is only used for categorical data types. For numerics use
hto discretize them firsth (tuple, optional) –
Interval width of the
VastColumns1 and 2 bars.Important
Only valid if the
VastColumnsare numerical. Optimizedhwill 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
VastColumnsis binary and themethod='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 barh plots:
1D
2D
data.barh(["grade"])
data.barh(columns = ["grade", "gender"])