gpt4 book ai didi

r - 忽略未知的美学 : text in ggplot (using numbers or letters as points)

转载 作者:行者123 更新时间:2023-12-02 18:46:47 27 4
gpt4 key购买 nike

我有这个数据集:

library(tidyverse)
dataset <- data.frame(CustomerId = c(1,2),
umap_01 = c(0.0198, -0.319),
umap_02 = c(0.336, -0.321))

我想用以下代码创建一个 ggplot:

p <- dataset %>%
ggplot(aes(umap_01,umap_02)) +
geom_point(aes(text = CustomerId), alpha = 0.5)

但是我收到了这条消息:

Warning message:
Ignoring unknown aesthetics: text

我不明白为什么文本是一种有效的美学。拜托,你能帮我这个代码吗?我做错了什么?

最佳答案

另一个选择是使用形状。如果您将一列数据传递到 aes 中,则需要使用 scale_shape_identityI()

library(tidyverse)
dataset <- data.frame(CustomerId = c(1,2),
umap_01 = c(0.0198, -0.319),
umap_02 = c(0.336, -0.321))
dataset %>%
ggplot(aes(umap_01,umap_02)) +
geom_point(aes(shape = I(as.character(CustomerId))), size = 10, alpha = 0.5)

reprex package 于 2021 年 4 月 30 日创建(v2.0.0)

关于r - 忽略未知的美学 : text in ggplot (using numbers or letters as points),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67334854/

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