Skip to content

Legend placement when wider than individual panels #144

@sbuis

Description

@sbuis

Description

When generating multi-panel plots with plot() in CroPlotR, the legend is currently positioned beside the panels (default behavior).

However, when the legend is wider than a single panel (e.g., many groups, long labels, or both), this results in compressed panels and poor readability.

In such cases, placing the legend to the right of the panels negatively impacts the visual clarity of the figure.

Expected behavior

If the legend width exceeds the width of a single panel, the legend should automatically be placed below the plots, rather than beside them.

Suggested implementation

  • Detect legend grob width relative to panel width.
  • If legend width > panel width:
    • Switch legend position to "bottom".
  • Otherwise, keep the default placement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions