great_tables
  • Get Started
  • Examples
  • Reference
  • Blog
  1. Theming
  2. Premade Themes
  • Intro
  • Overview
  • Table Structure
    • Header and Footer
    • Stub (Row Labels)
    • Column Labels
  • Format
    • Formatting Values
    • Nanoplots
  • Style
    • Styling the Table Body
    • Styling the whole table
    • Colorizing with Data
  • Theming
    • Table Theme Options
    • Premade Themes
  • Selecting table parts
    • Column Selection
    • Row Selection
    • Location selection
  • Extra
    • Contributing Guidelines

On this page

  • opt_stylize(): premade themes
  • opt_*() convenience methods
    • Align table header
    • Make text ALL CAPS
    • Reduce or expand padding
    • Set table outline
  1. Theming
  2. Premade Themes

Premade Themes

Great Tables provides convenience methods starting with opt_ (e.g. GT.opt_row_striping()), as a shortcut for various styles that can be set via GT.tab_options().

There are two important kinds of GT.opt_*() methods:

  • GT.opt_stylize(): allows setting one of six premade table themes.
  • The remaining GT.opt_*() methods: shortcuts for common uses of GT.tab_options().

We’ll use the basic GT object below for most examples, since it marks some of the table parts.

from great_tables import GT, exibble, md

lil_exibble = exibble.head(5)[["num", "char", "row", "group"]]

gt_ex = (
    GT(lil_exibble, rowname_col="row", groupname_col="group")
    .tab_header(
        title=md("Data listing from exibble"),
        subtitle=md("This is a **Great Tables** dataset."),
    )
    .tab_stubhead(label="row")
    .fmt_number(columns="num")
    .fmt_currency(columns="currency")
    .tab_source_note(source_note="This is only a portion of the dataset.")
    .opt_vertical_padding(scale=0.5)
)

gt_ex
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.

opt_stylize(): premade themes

Below are the first two premade styles. The first uses color="blue", and the second uses color="red".

gt_ex.opt_stylize(style=1, color="blue")
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
gt_ex.opt_stylize(style=2, color="red")
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.

Notice that first table (blue) emphasizes the row labels with a solid background color. The second table (red) emphasizes the column labels, and uses solid lines to separate the body cell values. See opt_stylize() for all available color options.

There are six styles available, each emphasizing different table parts. The style= values are numbered from 1 to 6:

1
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
2
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
3
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
4
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
5
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
6
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.

opt_*() convenience methods

This section shows the different GT.opt_*() methods available. They serve as convenience methods for common GT.tab_options() tasks.

Align table header

gt_ex.opt_align_table_header(align="left")
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.

Make text ALL CAPS

gt_ex.opt_all_caps()
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.

Reduce or expand padding

gt_ex.opt_vertical_padding(scale=0.3)
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
gt_ex.opt_horizontal_padding(scale=3)
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.

Set table outline

gt_ex.opt_table_outline()
Data listing from exibble
This is a Great Tables dataset.
row num char
grp_a
row_1 0.11 apricot
row_2 2.22 banana
row_3 33.33 coconut
row_4 444.40 durian
grp_b
row_5 5,550.00
This is only a portion of the dataset.
Table Theme Options
Column Selection