Reputation: 21
I am trying to override my symbol size aes using commands I have found in this forum and elsewhere. I can get the alpha override to work but not the size.
f1<-ggplot(data=d, aes(x=rpos, y=count, group=id,color=id)) +
geom_point(alpha=0.05, size=0.5) +
scale_fill_manual(values=c("blue", "red")) +
scale_colour_manual(values=c("blue", "red")) +
xlab("Chromosome 1") +
scale_y_continuous(name="Relative coverage",limits=c(-0.5,1.5)) +
guides(colour =guide_legend(override.aes=list(size=5))) +
guides(colour = guide_legend(override.aes = list(alpha = 1))) +
theme_bw()
optns <- theme (
plot.title = element_text(face="bold", size=14),
axis.title.x = element_text(size=12),
axis.title.y = element_text(size=12, angle=90),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.position = c(.97,.85),
legend.text = element_text(size=10),
legend.key.size = unit(1, "lines"),
legend.key = element_blank(),
legend.justification = 'right'
)
f1 + ggtitle ("Coverage of Chromosome 1") +
optns + ggsave("Rel.mergedDataChr1.pdf", width = 20, height = 5, dpi = 100)
Upvotes: 2
Views: 6614
Reputation: 146224
Your alpha override is overwriting your size override. Change this:
guides(colour = guide_legend(override.aes = list(size=5))) +
guides(colour = guide_legend(override.aes = list(alpha = 1))) +
to this:
guides(colour = guide_legend(override.aes = list(size=5, alpha = 1))) +
In the future, please try to include minimal working examples. This means both providing data (to make it a working example) and also not bothering with things like all your optns
(to keep it minimal).
Upvotes: 8