我有这个情节,当group2 = 0时,我将点的大小设置为0,将alpha设置为.000000000001,因为我想使这些点不可见。但你仍然可以看到图表上的圆圈。知道如何让那个圆圈完全不可见吗?
library(ggplot2)
dat = data.frame(label = c("A","B","C","D"), group1 = c(1,2,3,.02), group2 = c(3,4,5,0), color1 = c("lightblue","lightblue","lightblue","lightblue") ,
color12 = c("blue","blue","blue","blue"))
dat$sizze = ifelse(dat$group2 ==0 ,0, 2 )
dat$alpha = ifelse(dat$group2 ==0 ,0.0000000000001, 1 )
p1 <- ggplot(dat, aes(x = label, y = group1, fill = color1))+
geom_bar(stat="identity") +
geom_point(data = dat, aes(x = label, y = group2, color = color12, size = sizze, alpha = alpha))
p1 +
scale_size(guide='none', range=c(2) ) +
scale_fill_manual(values = c('lightblue' = 'lightblue'),
name = 'bar legend')+
scale_colour_manual(values = c('blue' = 'blue'),
name = 'point legend')