Skip to content

auto-determine y-axis expansion in plotSelectionProb #88

@mbstadler

Description

@mbstadler

Currently, we use plotSelectionProb(..., ylimext = 0.2) to make some room for the bar labels in y direction.

It would be convenient if that were automatically determined, but that seems not totally straightforward.

I tried:

  • manually calculate the text width using convertWidth(gropWidth(textGrob(text, gp = gpar(...)))) using information from ggplot_build(gg)$data[[2]], and then use that in gg + expand_limits(y), but that seems complicated
  • use geom_text_repel instead of geom_text, but that has the same issue, i.e. it constrains the labels to the plotting area

The underlying issue may be that the text dimensions are constant (given the text size and label string), while the axis size depends on the plotting device dimensions, and thus for example the axis expansion in data units would need to be re-calculated when a plot size is changed, while the text size would remain the same.

Maybe there is a more elegant solution?

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