The gt_plt_bullet() function takes an existing GT object and adds bullet chart visualizations to compare actual values against target values. Each bullet chart consists of a horizontal bar representing the actual value and a vertical line indicating the target value, making it easy to assess performance against goals or benchmarks.
Parameters
gt:GT
A GT object to modify.
data_column:SelectExpr
The column containing the actual values to be plotted as horizontal bars.
target_column:SelectExpr
The column containing the target values to be displayed as vertical reference lines. This column will be automatically hidden from the returned table.
fill:str='purple'
The fill color for the horizontal bars representing actual values.
bar_height:float=20
The height of each horizontal bar in pixels.
height:float=30
The height of the bullet chart plot in pixels. This allows for spacing around the bar and target line.
width:float=60
The width of the maximum bar in pixels. Bars are scaled proportionally to this width.
target_color:str='darkgrey'
The color of the vertical target line.
stroke_color:str | None='black'
The color of the vertical axis on the left side of the chart. The default is black, but if None is passed, no stroke will be drawn.
keep_data_column:bool=False
Whether to keep the original data 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 bullet chart plots added to the specified data column. The target column is automatically hidden from the table.
Both data and target values are scaled to a common domain for consistent visualization. The scaling domain is automatically determined as [0, max(data_values, target_values)].