I have below ggplot
:
library(ggplot2)
library(ggtext)
library(ggdist)
library(latex2exp)
set.seed(123)
DF <- rbind(data.frame('Label' = 'A', val = rnorm(200, 5)),
data.frame('Label' = 'B', val = rnorm(500, 10)))
ggplot(DF, aes(Label, val)) +
stat_dots(aes(fill = Label)) +
geom_textbox(aes(-Inf, -Inf, hjust = 0, vjust = 0, label = parse(text = TeX(r'(\tau)'))), data.frame())
Basically I want to write LaTeX
syntax inside a textbox
in ggplot
window. Here I have given a small example, however in my original case I have a big LaTeX
expression.
With above code, I am getting below error :
Don't know how to automatically pick scale for object of type expression. Defaulting to continuous.
Error: Aesthetics must be valid data columns. Problematic aesthetic(s): label = parse(text = TeX("\\tau")).
Did you mistype the name of a data column or forget to add after_stat()?
Any pointer how to use LaTeX
within a textbox
in ggplot
will be very helpful.
Thanks for your pointer.