我有以下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())
基本上我想在窗口LaTeX
内编写语法。这里我举了一个小例子,但在我原来的例子中,我有一个很大的表达。textbox
ggplot
LaTeX
使用上面的代码,我得到以下错误:
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()?
任何如何LaTeX
在textbox
in中使用的指针ggplot
都会非常有帮助。
谢谢你的指点。