gpt4 book ai didi

r - ggplot2 - 删除 R 中的大小图例

转载 作者:行者123 更新时间:2023-12-02 15:35:07 24 4
gpt4 key购买 nike

我想删除右侧的 20 码图例。下面是我的代码:

qplot(lingLocation[ind,ind_water_fountain]/lingLocation[ind,1], 
lingLocation[ind,ind_soda]/lingLocation[ind,1],
color = lingLocation[ind,ind_frosting]/lingLocation[ind,1], size = 20) +
# opts(legend.position = "none") +
scale_colour_gradient("Frosting %", low = "blue", high = "red") +
ylab("Soda %") +
xlab("Water Fountain %")

谢谢!

my plot

最佳答案

尝试从 qplot 调用中删除 size=20 参数,并将其粘贴到 geom_point 调用中。

例如,将您的代码更改为:

qplot(lingLocation[ind,ind_water_fountain]/lingLocation[ind,1], 
lingLocation[ind,ind_soda]/lingLocation[ind,1],
color = lingLocation[ind,ind_frosting]/lingLocation[ind,1]) +
# opts(legend.position = "none") +
scale_colour_gradient("Frosting %", low = "blue", high = "red") +
ylab("Soda %") +
xlab("Water Fountain %") +
geom_point(size=20)

我没有使用 qplot 函数,但我认为它应该可以工作。我相信 ggplot2 为每个 geom 中的每个美学调用添加了一个比例,这可能是 qplot 正在做的。但是由于您将大小应用于所有点,因此在 aes 之外设置大小参数应该会达到相同的效果,并且 size=20 不会生成图例它(我认为)。 geom_point 应该继承 qplot 的美学(我希望)。

让我知道这是否可行!

编辑:

我刚测试过。将大小放在 geom_point 内应该可行。但是,qplot 中的大小设置似乎与从 geom_point 中调用时的大小设置不同,因此可能在 geom_point 中设置较小的大小应该做这个把戏(比如,geom_point(size=5))

关于r - ggplot2 - 删除 R 中的大小图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19057657/

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