gpt4 book ai didi

r - 在 ggplot2 geom_text 中使用 plotmath 符号 - 图例已更改 - 为什么?

转载 作者:行者123 更新时间:2023-12-02 07:40:44 27 4
gpt4 key购买 nike

我想使用 ggplot2 在绘图中定位绘图数学符号(x 条)。不知何故,我这样做的方式改变了传说。字母“a”突然出现。我哪里出错了?

d <- data.frame(x=rnorm(10), y=rnorm(10), g=rep(c("m", "w"), 5))
ggplot(d, aes(x, y, group=g, color=g)) + geom_point() +
geom_text(x=0, y=0, label="bar(x)", parse=T)

最佳答案

这将解决问题:

ggplot(d, aes(x, y, group = g)) +   
geom_point(aes(colour = g)) +
geom_text(x = 0, y = 0, label = "bar(x)", parse=T)

只给点上色。

或者,如果你想注释图,注释将不会放在图例中,所以

ggplot(d, aes(x, y, group = g,colour = g)) +   
geom_point() +
annotate('text',x = 0, y = 0, label = "bar(x)", parse=T)

会起作用。

关于r - 在 ggplot2 geom_text 中使用 plotmath 符号 - 图例已更改 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11408031/

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