[英]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_point
在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
(例如geom_point(size=5)
)。
qplot
假定size
规格是一个映射,因此会创建一个比例。 在这里,您只想将其设置为20,所以将size = 20
替换为size = I(20)
。 这会设置大小,并且不会创建比例(并且可能会使点比您预期的要大)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.