aphalo / ggpmisc

R package ggpmisc is an extension to ggplot2 and the Grammar of Graphics
https://docs.r4photobiology.info/ggpmisc
100 stars 6 forks source link

Enable multi-line use_label #32

Closed orgadish closed 2 years ago

orgadish commented 2 years ago

Currently, the sep argument in use_label cannot take a \n for output.type=expression, since plotmath doesn't directly understand \n. However, there are ways to use, for example, atop to make multi-line expressions.

It would be great if a multi-line use_label functionality was added. One way this might work is by behind the scenes interpreting sep="\n" to trigger multiline atop functionality.

aphalo commented 2 years ago

@orgadish R expressions cannot contain a new line. Using atop is possible but alignment is not always the desired one. This is a limittaion in R itself. An alternative is to use markdown with geom_richtext() from package 'ggtext'. This approach is not yet fully polished, but works in most cases. If you encounter problems, I will try to help. (sorry about my previous comment, now deleted, which was intended for a different issue.)