---
title: Examples
notebook-links: false
toc: false
---

<style>
iframe {
    overflow: hidden;
}

h3 {
    text-align: center;
}

h3 a {
    text-decoration: none;
    font-size: 20px;
}

/* Turn off weird quarto whitespace behavior */
.masonry-item > p,
.mega-example-item > p {
  margin: 0;
  padding: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.mega-example-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1em;
}

.masonry-container {
  column-count: auto;
  /* Effectively determines number of columns (wider = fewer cols) */
  column-width: 11rem;
  column-gap: 1em;
}

.masonry-item,
.mega-example-item {
  display: inline-block;
  width: 100%;
  margin-bottom: 1em;
  position: relative;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
}

.embed-hover-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 2;
    border-radius: 8px;
    text-align: center;
    font-size: 1em;
}

.masonry-item:hover .embed-hover-overlay,
.mega-example-item:hover .embed-hover-overlay {
  opacity: 1;
  pointer-events: auto;
}

.masonry-item .cell-output table {
  zoom: calc(260/var(--width) * var(--dynamic-factor));
}

.mega-example-item .cell-output table {
  zoom: calc( 1 / 2600 * var(--mega-container-width));
}

.mega-example-item .cell-output #mycombinedtable {
  zoom: 0.47;
  padding-top: 30px;
}
</style>

<script>
function updateZoom() {
  const container = document.querySelector('.masonry-item');
  if (!container) return;

  const width = container.offsetWidth;
  const factor = Math.max(0.3, Math.min(2.5, width / 300));

  document.documentElement.style.setProperty('--dynamic-factor', factor);

  // similar, but for mega examples
  const mega_example_container = document.querySelector('.mega-example-container');
  if (!mega_example_container) return;

  const mega_example_width = mega_example_container.offsetWidth;
  document.documentElement.style.setProperty('--mega-container-width', mega_example_width);
}

addEventListener('DOMContentLoaded', updateZoom);
addEventListener('resize', updateZoom);

function setTableWidths() {
    document.querySelectorAll('.masonry-item').forEach(item => {
        // Skip fixed width for gt_two_column_layout
        if (
            item.querySelector('[href*="with-code.html#gt_two_column_layout"]') ||
            item.querySelector('#cell-gt_two_column_layout')
        ) {
            item.style.setProperty('--width', 631);
            return;
        }
        const table = item.querySelector('.cell-output table');
        if (table) {
            // Set the --width CSS variable on the masonry item to the rendered width
            const tableWidth = table.offsetWidth;
            item.style.setProperty('--width', tableWidth);
        }
    });
}

addEventListener('DOMContentLoaded', setTableWidths);
addEventListener('resize', setTableWidths);
</script>

::::{.mega-example-container}

:::{.mega-example-item style="--width: 724;"}
{{< embed with-code.qmd#cars_table >}}
[Cars](./with-code.html#cars_table){.embed-hover-overlay}
:::

:::{.mega-example-item style="--width: 763;"}
{{< embed with-code.qmd#nfl_table >}}
[NFL 2011 Season](./with-code.html#nfl_table){.embed-hover-overlay}
:::

:::{.mega-example-item style="--width: 756;"}
{{< embed with-code.qmd#gini_coefficient_table >}}
[Gini Coefficients](./with-code.html#gini_coefficient_table){.embed-hover-overlay}
:::

::::

::::{.masonry-container}

<!-- Override width in case they render slowly -->
:::{.masonry-item style="--width: 686;"}
{{< embed with-code.qmd#gt_plt_bar >}}
[gt_plt_bar](./with-code.html#gt_plt_bar){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 249;"}
{{< embed with-code.qmd#gt_plt_bar_pct >}}
[gt_plt_bar_pct](./with-code.html#gt_plt_bar_pct){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 297;"}
{{< embed with-code.qmd#gt_plt_bar_stack >}}
[gt_plt_bar_stack](./with-code.html#gt_plt_bar_stack){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 323;"}
{{< embed with-code.qmd#gt_plt_bullet >}}
[gt_plt_bullet](./with-code.html#gt_plt_bullet){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 376;"}
{{< embed with-code.qmd#gt_plt_conf_int >}}
[gt_plt_conf_int](./with-code.html#gt_plt_conf_int){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 623;"}
{{< embed with-code.qmd#gt_plt_donut >}}
[gt_plt_donut](./with-code.html#gt_plt_donut){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 304;"}
{{< embed with-code.qmd#gt_plt_dot >}}
[gt_plt_dot](./with-code.html#gt_plt_dot){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 413;"}
{{< embed with-code.qmd#gt_plt_dumbbell >}}
[gt_plt_dumbbell](./with-code.html#gt_plt_dumbbell){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 521;"}
{{< embed with-code.qmd#gt_plt_summary >}}
[gt_plt_summary](./with-code.html#gt_plt_summary){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 167;"}
{{< embed with-code.qmd#gt_plt_winloss >}}
[gt_plt_winloss](./with-code.html#gt_plt_winloss){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 211;"}
{{< embed with-code.qmd#gt_color_box >}}
[gt_color_box](./with-code.html#gt_color_box){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 347;"}
{{< embed with-code.qmd#gt_data_color_by_group >}}
[gt_data_color_by_group](./with-code.html#gt_data_color_by_group){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 323;"}
{{< embed with-code.qmd#gt_highlight_cols >}}
[gt_highlight_cols](./with-code.html#gt_highlight_cols){.embed-hover-overlay}
:::

:::{.masonry-item}
{{< embed with-code.qmd#gt_highlight_rows >}}
[gt_highlight_rows](./with-code.html#gt_highlight_rows){.embed-hover-overlay}
:::

:::{.masonry-item}
{{< embed with-code.qmd#gt_hulk_col_numeric >}}
[gt_hulk_col_numeric](./with-code.html#gt_hulk_col_numeric){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 380;"}
{{< embed with-code.qmd#gt_theme_538 >}}
[gt_theme_538](./with-code.html#gt_theme_538){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 359;"}
{{< embed with-code.qmd#gt_theme_espn >}}
[gt_theme_espn](./with-code.html#gt_theme_espn){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 388;"}
{{< embed with-code.qmd#gt_theme_guardian >}}
[gt_theme_guardian](./with-code.html#gt_theme_guardian){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 308;"}
{{< embed with-code.qmd#gt_theme_nytimes >}}
[gt_theme_nytimes](./with-code.html#gt_theme_nytimes){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 365;"}
{{< embed with-code.qmd#gt_theme_excel >}}
[gt_theme_excel](./with-code.html#gt_theme_excel){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 378;"}
{{< embed with-code.qmd#gt_theme_dot_matrix >}}
[gt_theme_dot_matrix](./with-code.html#gt_theme_dot_matrix){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 379;"}
{{< embed with-code.qmd#gt_theme_dark >}}
[gt_theme_dark](./with-code.html#gt_theme_dark){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 283;"}
{{< embed with-code.qmd#gt_theme_pff >}}
[gt_theme_pff](./with-code.html#gt_theme_pff){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 274;"}
{{< embed with-code.qmd#add_text_img >}}
[add_text_img](./with-code.html#add_text_img){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 657;"}
{{< embed with-code.qmd#fa_icon_repeat >}}
[fa_icon_repeat](./with-code.html#fa_icon_repeat){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 451;"}
{{< embed with-code.qmd#gt_fa_rank_change >}}
[gt_fa_rank_change](./with-code.html#gt_fa_rank_change){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 525;"}
{{< embed with-code.qmd#gt_fa_rating >}}
[gt_fa_rating](./with-code.html#gt_fa_rating){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 304;"}
{{< embed with-code.qmd#gt_fmt_img_circle >}}
[gt_fmt_img_circle](./with-code.html#gt_fmt_img_circle){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 355;"}
{{< embed with-code.qmd#img_header >}}
[img_header](./with-code.html#img_header){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 369;"}
{{< embed with-code.qmd#fmt_pct_extra >}}
[fmt_pct_extra](./with-code.html#fmt_pct_extra){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 745;"}
{{< embed with-code.qmd#gt_add_divider >}}
[gt_add_divider](./with-code.html#gt_add_divider){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 338;"}
{{< embed with-code.qmd#gt_duplicate_column >}}
[gt_duplicate_column](./with-code.html#gt_duplicate_column){.embed-hover-overlay}
:::

:::{.masonry-item}
{{< embed with-code.qmd#gt_merge_stack >}}
[gt_merge_stack](./with-code.html#gt_merge_stack){.embed-hover-overlay}
:::

:::{.masonry-item style="padding-top: 15px;"}
{{< embed with-code.qmd#gt_two_column_layout >}}
[gt_two_column_layout](./with-code.html#gt_two_column_layout){.embed-hover-overlay}
:::

:::{.masonry-item style="--width: 201;"}
{{< embed with-code.qmd#with_hyperlink >}}
[with_hyperlink](./with-code.html#with_hyperlink){.embed-hover-overlay}
:::

:::{.masonry-item}
{{< embed with-code.qmd#with_tooltip >}}
[with_tooltip](./with-code.html#with_tooltip){.embed-hover-overlay}
:::

::::
