The gt_plt_bar() function takes an existing GT object and adds horizontal bar charts to specified columns. Each cell value is represented as a horizontal bar with length proportional to the cell’s numeric value relative to the column’s maximum value.
Parameters
gt:GT
A GT object to modify.
columns:SelectExpr=None
The columns to target. Can be a single column or a list of columns (by name or index). If None, the bar plot is applied to all numeric columns.
fill:str='purple'
The fill color for the bars.
bar_height:float=20
The height of each individual bar in pixels.
height:float=30
The height of the bar plot in pixels. In practice, this allows for the bar to appear less stout, the larger the difference between height and bar_height.
width:float=60
The width of the maximum bar in pixels. Not all bars will have this width.
stroke_color:str | None='black'
The color of the vertical axis on the left side of the bar. The default is black, but if None is passed, no stroke will be drawn.
show_labels:bool=False
Whether or not to show labels on the bars.
label_color:str='white'
The color of text labels on the bars (when show_labels is True).
keep_columns:bool=False
Whether to keep the original column values. If this flag is True, the plotted values will be duplicated into a new column with the string ” plot” appended to the end of the column name. See gt_duplicate_column() for more details.
Returns
:GT
A GT object with horizontal bar plots added to the specified columns.