There doesn't seem to be a consistent solution for this issue (for me, at least) but I've got a solution here:
library(tidyverse)
df1 <- data.frame(correlation = c(rnorm(1000, 0, 0.6), rnorm(1000, 0, 0.1)), type = c(rep("Real", 1000), rep("Permuted", 1000)))
corSig <- 0.24542
ggplot(df1, aes(correlation, fill = type)) +
geom_density(alpha = .5) +
geom_vline(aes(xintercept = signif(corSig, 2), linetype = 'FDR = .05'), colour = 'red') +
theme(
plot.title = element_text(hjust = .5),
plot.subtitle = element_text(hjust = .5),
legend.title = element_blank(),
legend.position = c(.8, .8),
panel.background = element_blank(),
legend.key = element_rect(colour = "transparent", fill = "transparent")) +
ggtitle("Gene Expression Correlation", subtitle = paste(nrow(df1), "genes,", ncol(df1), "bulk sections")) +
xlab("Correlation") +
ylab("Density")
Fixed Gene Expression Correlation Plot
In short, I removed ...guides(linetype = guide_legend(override.aes = list(fill = "#000000")))...
and added ...legend.key = element_rect(colour = "transparent", fill = "transparent"))...
Hopefully that helps!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…