[英]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.