不是通过ggplot2 / latex2xp在图中提供的“二项式”乳胶符号

问题描述 投票:0回答:1

我需要在y轴上编写一个在Latex中使用binom sintax的公式,但是,似乎不支持该公式。

library(ggplot2)
library(latex2exp)
fx.2b <- function(x, theta){
  choose(100, x)*exp((x*log(theta/(1-theta)) + 100*log(1-theta)))
}
df <- data.frame(x = rep(1:100, times = 5),
                 theta = rep(c(0.01, 0.1, 0.3, 0.5, 0.9), each = 100))
df$y <- fx.2b(df$x, df$theta)
df$theta <- as.factor(df$theta)
ggplot(data = df, aes(x = x, y = y, color = theta)) +
  geom_line() +
  labs(y = TeX("$f(x; \\theta) = \\binom{100}{x} \\exp (x \\log (\\frac{\\theta}{1-\\theta}) + 100 \\log (1 - \\theta))$"))

enter image description here

我的乳胶配方正确:

f(x; \ theta)= \ binom {100} {x} \ exp(x \ log(\ frac {\ theta} {1- \ theta})+ 100 \ log(1-\ theta))] >

https://www.codecogs.com/latex/eqneditor.php中完美显示。

我该如何纠正?

提前感谢。

我需要在y轴上编写一个公式,该公式在Latex中使用Binom sintax,但是似乎不支持该公式。库(ggplot2)库(latex2exp)fx.2b

r ggplot2 latex
1个回答
0
投票

您可以直接使用plotmath。从help("plotmath")

© www.soinside.com 2019 - 2024. All rights reserved.