Skip to content

Changing legend_key_height Does Not Affect Legend Fill Box Height #921

Closed

Description

@nick-youngblut

Description:
I have encountered an issue with plotnine where setting legend_key_height in the theme does not modify the height of the legend fill boxes as expected. Regardless of the value provided, the size of the legend keys remains unchanged.

Steps to Reproduce:

  1. Run the following code:
import pandas as pd
import plotnine as pn

df = pd.DataFrame({
    "category": ["A", "B", "C"],
    "organism": ["org1", "org2", "org1"],
    "value": [1, 2, 3]
})

p = (
    pn.ggplot(df, pn.aes(x="category", fill="organism")) +
    pn.geom_bar() +
    pn.theme(
        axis_text_x=pn.element_text(rotation=45, hjust=1),
        figure_size=(9, 5),
        legend_key_height=30
    )
)
p
  1. Observe that the legend key (fill box) height does not change despite setting legend_key_height to 30.

Expected Behavior:

The legend fill boxes should change in height according to the value provided by legend_key_height.

Actual Behavior:

The legend fill boxes remain unchanged regardless of the parameter value.

Environment:

•	Plotnine version: 0.14.5
•	Python version: 3.12.7
•	Operating System: Ubuntu 22.04.3

Activity

  1. added a commit that references this issue on Mar 17, 2025
    1bc2e58
  2. added a commit that references this issue on Mar 18, 2025
    6464121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions