The gt_plt_winloss() function takes an existing GT object and adds win/loss sparkline charts to a specified column. Each cell displays a series of small vertical bars representing individual game outcomes, This visualization is useful for showing performance streaks and patterns over time. All win/loss charts are scaled to accommodate the longest sequence in the column, ensuring consistent bar spacing across all rows.
Wins must be represented as 1, ties as 0.5, and losses as 0. Invalid values (not 0, 0.5, or 1) are skipped.
Parameters
gt:GT
A GT object to modify.
column:SelectExpr
The column containing lists of win/loss/tie values. Each cell should contain a list where: 1 represents a win, 0 represents a loss, and 0.5 represents a tie. Values that are not listed above are skipped.
width:float=80
The width of the win/loss chart in pixels.
height:float=30
The height of the win/loss chart in pixels.
win_color:str='blue'
The color for bars representing wins.
loss_color:str='red'
The color for bars representing losses.
tie_color:str='grey'
The color for bars representing ties.
shape:Literal['pill', 'square']='pill'
The shape style of the bars. Options are "pill" for taller bars or "square" for stockier, nearly square bars.
spacing:float=2
The horizontal gap, in pixels, between each bar. Note that if the spacing is too large, it may obstruct the bars from view.
Returns
:GT
A GT object with win/loss charts added to the specified column.
Examples
First, let’s make a table with randomly generated data: