繁体   English   中英

ggplot2-删除R中的尺寸图例

[英]ggplot2 - removing size legend in R

我想删除右侧的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 %")

谢谢!

我的情节

尝试从qplot调用中删除size=20参数,并将其geom_pointgeom_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 (例如geom_point(size=5) )。

qplot假定size规格是一个映射,因此会创建一个比例。 在这里,您只想将其设置为20,所以将size = 20替换为size = I(20) 这会设置大小,并且不会创建比例(并且可能会使点比您预期的要大)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM