Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate better wrapping functions for decorate_grob titles and subtitles #1248

Closed
Melkiades opened this issue May 24, 2024 · 0 comments
Closed
Labels
discussion sme wontfix This will not be worked on

Comments

@Melkiades
Copy link
Contributor

follow-up of fix #1245. The complex point here that prevents us to go all the way to the ggplot2 world is composite plots made with plot_grid (cowplot). I tried to annotate these but no wrapping is possible in anyway and this defies one important role of decorate_grob. The current wrapping method is copied from a book and uses effectively base wrapping to do it and it calculates the width with the following:

 # Main conversion of allowed text width -> npc units are 0<npc<1. External viewport is used for conversion
        if (grid::convertWidth(linewidth + gapwidth + width_i, grid::unitType(width), valueOnly = TRUE) < availwidth) {

npc is normalised to the width of the viewport and makes transforming all of this to number of characters difficult and problematic as it is already buggy for rstudio and other unclear viewports. Hence, I would not try for now to use formatters::wrap_text that keeps also spaces and respects \n.

In summary:

  1. We cant use ggplot2 decorations because plot_grid does not wrap
  2. We need to think more about using other wrapping algorithms as the current method works and others may present difficult conversions of viewport sizes
@Melkiades Melkiades added wontfix This will not be worked on sme discussion labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion sme wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant