gt-extras
  • Intro
  • API Reference
  1. Icons and Images
  2. img_header
  • API Reference
  • Plotting
    • gt_plt_bar
    • gt_plt_bar_pct
    • gt_plt_bar_stack
    • gt_plt_conf_int
    • gt_plt_dot
    • gt_plt_dumbbell
    • gt_plt_winloss
  • Colors
    • gt_color_box
    • gt_data_color_by_group
    • gt_highlight_cols
    • gt_highlight_rows
    • gt_hulk_col_numeric
  • Themes
    • gt_theme_538
    • gt_theme_dark
    • gt_theme_dot_matrix
    • gt_theme_espn
    • gt_theme_excel
    • gt_theme_guardian
    • gt_theme_nytimes
    • gt_theme_pff
  • Icons and Images
    • add_text_img
    • fa_icon_repeat
    • gt_fa_rank_change
    • gt_fa_rating
    • img_header
  • Utilities
    • fmt_pct_extra
    • gt_add_divider
    • gt_duplicate_column
    • gt_merge_stack
    • gt_two_column_layout
    • with_hyperlink
    • with_tooltip

On this page

  • Parameters
  • Returns
  • Examples
  • See Also
  1. Icons and Images
  2. img_header

img_header

img_header(
    label,
    img_url,
    height=60,
    font_size=12,
    border_color='black',
    text_color='black',
)

Create an HTML header with an image and a label, suitable for a column label.

Parameters

label : str

The text label to display below the image.

img_url : str

The URL of the image to display. This can be a filepath or an image on the web.

height : float = 60

The height of the image in pixels.

font_size : int = 12

The font size of the label text.

border_color : str = 'black'

The color of the border below the image.

text_color : str = 'black'

The color of the label text.

Returns

: html

A Great Tables html element for the header.

Examples

import pandas as pd
from great_tables import GT, md
import gt_extras as gte

df = pd.DataFrame(
    {
        "Category": ["Points", "Rebounds", "Assists", "Blocks", "Steals"],
        "Hart": [1051, 737, 453, 27, 119],
        "Brunson": [1690, 187, 475, 8, 60],
        "Bridges": [1444, 259, 306, 43, 75],
    }
)

hart_header = gte.img_header(
    label="Josh Hart",
    img_url="https://a.espncdn.com/combiner/i?img=/i/headshots/nba/players/full/3062679.png",
)

brunson_header = gte.img_header(
    label="Jalen Brunson",
    img_url="https://a.espncdn.com/combiner/i?img=/i/headshots/nba/players/full/3934672.png",
)

bridges_header = gte.img_header(
    label="Mikal Bridges",
    img_url="https://a.espncdn.com/combiner/i?img=/i/headshots/nba/players/full/3147657.png",
)

(
    GT(df, rowname_col="Category")
    .tab_source_note(md("Images and data courtesy of [ESPN](https://www.espn.com)"))
    .cols_label(
        {
            "Hart": hart_header,
            "Brunson": brunson_header,
            "Bridges": bridges_header,
        }
    )
)
Josh Hart
Jalen Brunson
Mikal Bridges
Points 1051 1690 1444
Rebounds 737 187 259
Assists 453 475 306
Blocks 27 8 43
Steals 119 60 75
Images and data courtesy of ESPN

See Also

add_text_img()

gt_fa_rating
fmt_pct_extra