The gt_plt_donut() function takes an existing GT object and adds donut charts to specified columns. Each cell value is represented as a portion of a full donut chart, with the chart size proportional to the cell’s numeric value relative to the column’s maximum value. The maximum value in the column will display as a full circle.
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 donut chart is applied to all numeric columns.
fill:str='purple'
The fill color for the donut chart segments.
size:float=30
The diameter of the donut chart in pixels.
stroke_color:str | None=None
The color of the border around the donut chart. If None, no stroke will be drawn, except for the case of the 0 value.
stroke_width:float=1
The width of the border stroke in pixels.
show_labels:bool=False
Whether or not to show labels on the donut charts.
label_color:str='black'
The color of text labels on the donut charts (when show_labels is True).
domain:list[int] | list[float] | None=None
The domain of values to use for scaling. This can be a list of floats or integers. If None, the domain is automatically set to [0, max(column_values)].
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 donut charts added to the specified columns.
Each column’s donut charts are scaled independently based on that column’s min/max values. A value equal to the column maximum will display as a full circle (360 degrees).