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:
We cant use ggplot2 decorations because plot_grid does not wrap
We need to think more about using other wrapping algorithms as the current method works and others may present difficult conversions of viewport sizes
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: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 useformatters::wrap_text
that keeps also spaces and respects\n
.In summary: