gpt4 book ai didi

R 基本图形 : Annotate with logical symbols (and/or)

转载 作者:行者123 更新时间:2023-12-02 00:06:00 25 4
gpt4 key购买 nike

我想添加逻辑符号 and (∧) 和 or (∨) 到 R 中的基础图.

我认为要走的路可能会使用表达式,但我无法弄清楚如何,因为他们的 unicode 代码 \u2227\u2228不工作。可能是因为我在 Windows 上(win 7、64 位)。

我有什么:

plot(1, 1, pch = "")
text(1, 1.2,
expression(paste("low ", italic(P), "(", italic(p), " and ", italic(q),
"), -1 SD")), cex = 1.2)
text(1, 0.8,
expression(paste("low ", italic(P), "(\u00ac", italic(p), " or ", italic(q),
"), -1 SD")), cex = 1.2)

enter image description here

我想替换文字 andor与他们的符号对应。

最佳答案

Symbol 字体映射的使用细节在:

?plotmath
?points # to which plotmath sends you for mapping of 'symbol' characters

# And I do not like the plotmath-paste function,
# so translated to 'pure' expressions.
# The number arguments to symbol are numbers in octal.

plot(1, 1, pch = "")
text(1, 1.2,
expression(low ~italic(P)*"("*italic(p)~
symbol("\332")~ italic(q)*
"), -1 SD"),
cex = 1.2)
text(1, 0.8,
expression(low~italic(P)*
"("*symbol("\330")*italic(p)~symbol("\331")~ italic(q)*
"), -1 SD"),
cex = 1.2 )

这是请求显示符号字形及其十进制索引的代码。 (警告:这是 Mac 上的 Symbol 字体。不能保证这在任何地方都是一样的。)您仍然需要转换为八进制以引用以使用上面看到的形式“\nnn”:

> as.octmode(216)
[1] "330"

TestChars <- function(sign = 1, font = 1, ...)
{
MB <- l10n_info()$MBCS
r <- if(font == 5) { sign <- 1; c(32:126, 160:254)
} else if(MB) 32:126 else 32:255
if (sign == -1) r <- c(32:126, 160:255)
par(pty = "s")
plot(c(-1,16), c(-1,16), type = "n", xlab = "", ylab = "",
xaxs = "i", yaxs = "i",
main = "Symbol Font, Decimal Indices")
grid(17, 17, lty = 1) ; mtext(paste("MBCS:", MB))
for(i in r) try(points(i%%16, i%/%16, pch = sign*i, font = font,...))

for(i in r) try(text(x=i%%16, y=(i%/%16)-0.4, i, cex=0.5 , font = font,...))
}

TestChars(font = 5)

enter image description here

关于R 基本图形 : Annotate with logical symbols (and/or),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18346115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com