Skip to content

loc.spanner_labels does not work with multiple levels #688

@ChristopherRussell

Description

@ChristopherRussell

Prework

Description

great_tables.loc.spanner_labels does not work for levels above the lowest level

Reproducible example

from great_tables import GT, exibble, loc, style
gt = (
    GT(exibble.loc[[0, 1], ["char", "fctr", "row"]])
    .tab_spanner("spanner1_level0", ["fctr"], level=0)
    .tab_spanner("spanner2_level0", ["char"], level=0)
    .tab_spanner("spanner_level1", ["char", "fctr"], level=1)
)
color1 = "#a6cee3"
color2 = "#b15928"
(
    gt.tab_style(style.fill(color1), loc.spanner_labels(ids=["spanner1_level0"]))
    .tab_style(style.fill(color2), loc.spanner_labels(ids=["spanner2_level0"]))
    .tab_style(style.fill(color2), loc.spanner_labels(ids=["spanner_level1"]))
)
  • Post a minimal reproducible example (MRE) so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the Style Guide for Python Code.

Expected result

spanner_level1 should be filled with same color as spanner2_level0, but is not filled at all.

Development environment

  • Operating System: Linux
  • great_tables Version: 0.17.0

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions