gpt4 book ai didi

r - ggplot : some Unicode shapes working while others do not

转载 作者:行者123 更新时间:2023-12-03 16:21:19 30 4
gpt4 key购买 nike

这是一个简单的例子。

library(tidyverse)

dat <- data.frame(x = c(1,2,3,4,5),
y = c(1,2,3,4,5))

ggplot(dat, aes(x, y)) +
geom_point(shape="\u2620", size = 8)

这非常适合创建骷髅和交叉骨作为形状,如 2620 is the hex value for this unicode character .我实际上想要 elephant shape, which has the hex code 1F418 .

但是,将 1F418 替换为 2620 会产生错误消息

Error: Can't find shape name: * '8'



为什么大象形状不起作用?我怎样才能让大象的形状出现在我的情节中?

最佳答案

小写 \u转义前缀表示具有 16 位十六进制值的 Unicode 字符。对于 32 位十六进制值,使用大写 \U或代理对(两个 16 位值):

ggplot(dat, aes(x, y)) +
geom_point(shape="\U1F418", size = 8) # is "\U0001f418"

或者:
ggplot(dat, aes(x, y)) +
geom_point(shape="\uD83D\uDC18", size = 8)

enter image description here

关于r - ggplot : some Unicode shapes working while others do not,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61883118/

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