The results of bgroup
from plotmath
do not seem to render properly as a ggplot2
annotation. For example ...
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
annotate("text", x=2.5, y=25, label="bgroup('(',atop(x,y),')')", parse=TRUE) +
annotate("text", x=3.5, y=25, label="group('(',atop(x,y),')')", parse=TRUE)
... produces the following graph for me ...
Note how the bgroup
rendering on the left does not have large parentheses like I would expect (and worked in some previous version of R), whereas the reqular group
rendering to the right does seem to work.
Am I missing a font? Something else?
I am using R 4.2.2 and ggplot2 3.4.0.
EDITS:
- The code above worked properly in R versions 4.0.5, 4.1.0, 4.1.2, and 4.2.0 (and 3.6.3 according to Jamie in the comments .. but not on Linux according to an answer on R-help).
- The issue does not seem related to
ggplot2
as the same problem occurs with base graphics. - The same issue occurs with R version 4.2.2 whether the code is run in RStudio or the RGui.
- The same issue occurs (in R version 4.2.2) when the plot is directed to a PNG but not when it is directed to a PDF.
plot(0,xlim=c(0,1),ylim=c(0,1))
text(0.5,0.5,expression(bgroup('(',atop(x,y),')')))