【发布时间】:2018-04-28 21:21:38
【问题描述】:
我正在尝试使用 UTF-8 代码将符号放在 R 图中的某些文本中。如果我想要一个黑色圆圈,我可以使用代码 intToUtf8(9679)。在哪里可以找到列出其他符号值的数据库?我想找到创建红色圆圈的代码(即 pch=16,col="red"),但我找不到特定符号的所有 unicode 值的列表。
# example R code
x <- 1:10
y1 <- rnorm(10, x*2, 0.5)
y2 <- rnorm(10, x, 0.5)
plot(x, y1, xlab='x-value', ylab='', pch=16)
points(x, y2, pch=16, col='red')
mtext(paste0('value for y1 (', intToUtf8(9679), ') and y2 (', intToUtf8(9679), ')'), side=2, line=2)
# except that I want the second black circle in the axis label to be a red circle
感谢您的帮助, 米奇
【问题讨论】:
-
你想创造传奇吗?如果是,请查看帮助页面:
?legend。例如,legend("bottom", legend = c("y1", "y1"), col = c("black", "red"), pch = 16, ncol=2)并不是最糟糕的。 -
谢谢,但我宁愿只使用图例作为最后的选择。我希望在轴标签中包含信息,因为我的真实数据图没有图例的空间。
-
查看
?points()以获取点字符 (pch) 和 how to do multi-colored labels 的列表。旁注:您可以使用\u25CF而不是', intToUtf8(9679), '。 large red circle 也有一个 unicode,但我怀疑你是否让它在情节中工作。 -
谢谢@lukeA。我尝试了这些想法,我尝试了链接中的想法,但是在尝试将符号插入表达式命令时遇到问题:
mtext(expression('value for y1 (\u25CF) and y2 ('* phantom('\u25CF') * ')'), side=2, line=2)。但我想知道你怎么知道黑点是\u25CF?是否有表格显示这些值是什么??points下没有那么多信息 -
谢谢。我想我没有正确搜索。我仍然无法让它与红点的 unicode 一起使用。我最终遵循了multi-colored labels 提供的链接中的建议,但由于您不能同时使用
phantom命令和 unicode(因为 unicode 在expression中被误解),所以我只是在其中放了一堆空格文本直到到达我想要的位置。