我最近更新到ggplot2的版本2.2.0,但注意到運行我的代碼時與以前的版本不同。 之前,我使用下面的代碼來繪製第一個geom_point
系列的無邊框圓形(形狀21)。隨後,使用第二行geom_point
,我將使用黑色邊框來勾勒特定的圓圈(在這種情況下爲$disp > 200
)。下面是我自己的數據快照:當使用geom_point時,ggplot2 v2.2.0的行爲有何不同?
然而,隨着新GGPLOT2我不能夠繪製bordeless圓圈和其他標記像以前一樣。
是否有任何解決方法?
library(ggplot2)
gg <- ggplot(data=mtcars, aes(x=gear, y=mpg))
gg <- gg + geom_point(data=mtcars, aes(fill=hp, size=cyl), shape=21, col=NA)
gg <- gg + scale_fill_gradient(low="yellow", high="red")
gg <- gg + geom_point(data=mtcars[which(mtcars$disp>200),], aes(size=cyl), shape=21, col="Black")
gg
gg <- ggplot(data=mtcars, aes(x=gear, y=mpg))
gg <- gg + geom_point(data=mtcars, aes(fill=hp, size=cyl), shape=21)
gg <- gg + scale_fill_gradient(low="yellow", high="red")
gg <- gg + geom_point(data=mtcars[which(mtcars$disp>200),], aes(size=cyl), shape=21)
gg
UPDATE: 我嘗試添加stroke=0
按照下面的評論,但它似乎完全忽略它。也就是說,我仍然和我最後的形象一樣。
rm(gg)
gg <- ggplot(data=mtcars, aes(x=gear, y=mpg))
gg<- gg + geom_point(data=mtcars, aes(fill=hp, size=cyl), shape=21, stroke = 0)
gg
gg <- gg + scale_fill_gradient(low="yellow", high="red")
gg
gg<- gg + geom_point(data=mtcars[which(mtcars$disp>200),], aes(size=cyl), shape=21, stroke = 0)
gg
如此看來,當我將它設置爲0。
嘗試設置stroke = 0。奇怪的是,lwd = 0使點非常小 – baptiste
@baptiste:使用這個沒有區別:gg < - gg + geom_point(data = mtcars,aes(fill = hp,size = cyl,stroke = 0),shape = 21) – val
你必須將'stroke = 0'放在'aes'之外。例如:'geom_point(data = mtcars,aes(fill = hp,size = cyl),shape = 21,stroke = 0)' – h3rm4n