I have the following data:
trait,beta,se,p,analysis,signif
trait1,0.078,0.01,9.00E-13,group1,1
trait2,0.076,0.01,1.70E-11,group1,1
trait3,-0.032,0.01,0.004,group
Add dummy aes()
to geom_point
- for example fill that is named significant aes(fill = "Significant")
.
# Using OPs data
library(ggplot2)
ggplot(GEE, aes(y=beta, x=reorder(trait, beta), group=analysis)) +
geom_point(data = GEE[GEE$signif == 1, ],
color="red",
shape = "*",
size=12,
aes(fill = "Significant")) +
geom_point(aes(color=analysis)) +
geom_errorbar(aes(ymin=beta-2*se, ymax=beta+2*se,color=analysis), width=.2,
position=position_dodge(.2)) +
geom_hline(yintercept = 0) +
theme_light() +
theme(axis.title.y=element_blank(),
legend.title=element_blank()) +
coord_flip() +
guides(colour = guide_legend(order = 1),
fill = guide_legend(override.aes = list(size = 5))) +
theme(legend.margin = margin(-0.5,0,0,0, unit="cm"))
PS: I also removed show.legend = F
from asterik geom_point