Reputation: 9
My plot currently looks like this:
I want to change the shape in the legend (which is currently "a") for only points that indicate the respective colours. This is my code so far:
ggplot(data=pca2.data, aes(x=X, y=Y, label=Sample, colour = col)) +
geom_text() +
xlab(paste("PC1 - ", pca2.var.per[1], "%", sep="")) +
ylab(paste("PC2 - ", pca2.var.per[2], "%", sep="")) +
theme_bw() +
ggtitle("My PCA Graph") +
geom_hline(yintercept = 0) +
geom_vline(xintercept = 0) +
scale_color_manual(values=c("black", "red", "green"), labels = c("No significant difference", "Sharpe Decrease", "Sharpe Increase")) +
theme(legend.position = 'bottom') + guides(color=guide_legend(""))
I already tried adding "shape = c(20, 20, 20)" inside of "guide_legend", but it changed nothing.
Upvotes: 0
Views: 456
Reputation: 903
Just put an empty point layer and don't plot legend for geom_text
As you didn't provide data, I've used mtcars
dataset but it should translate to your problem
ggplot(mtcars, aes(mpg, cyl, label=rownames(mtcars), color=factor(carb))) +geom_point(shape=NA)+
geom_text( show.legend = F ) + guides(colour=guide_legend(override.aes = list(shape = 16)))
Upvotes: 1