我試圖通過聚簇來創建條件的氣泡圖,其中每個氣泡的大小由第三個「百分比」變量設置。至於per the ggplot2 documentation,我想我應該可以通過scale_size_area來做到這一點。我不清楚爲什麼這不起作用,當百分比= 0時,我仍然看到非常微小的點。使用scale_size_area(ggplot2)繪製大小爲「0」的點爲完全不存在
ex <- data.frame(Condition=rep(c("ex1","ex2","ex3","ex4"),4),
Cluster=c(rep(1,4),rep(2,4),rep(3,4),rep(4,4)),
Percent=c(0,0,0,1,0.25,0,0.25,0.5,1,0,0,0,0.25,0.25,0.25,0.25))
ggplot(ex, aes(Cluster, Condition, size=Percent))+
geom_point(color = "blue")+ scale_size_area(max_size=20)
E.g. 'size = ifelse(Percent == 0,NA,Percent))'而不是'size = Percent'? – lukeA
它可能與'stroke'(點的輪廓)有關。雖然我的印象是,只有21點到25點有一個輪廓,當'百分號'爲0時,在'geom_point'中使用'stroke = 0'將刪除點。 – aosmith
@lukeA工作!如果您想將其作爲答案發布,我很樂意接受它。 – dd3