I used the picture's numbers as data points in this scatterplot, which was created with ggplot2. As a result, the legend key is an 'a'. Instead, I would need ordinary dots (also colored by clusters) beside the labels. How can I realize that? I used the following code:
ggplot(data, aes(x=vx, y=vy, color=Cluster, shape=Cluster)) + geom_text(aes(label=PicNr),
size =6, fontface = "bold",
check_overlap = T,
show.legend=T) +
theme_bw(base_size = 20)+
theme(legend.position="top")
Thanks for your help!
For this you can do something like
library(ggplot2)
ggplot(mtcars, aes(mpg, wt))+
geom_text(aes(label = cyl, color = factor(cyl)), show.legend = FALSE)+
geom_point(aes(color = factor(cyl)), alpha = 0)+
guides(color = guide_legend(override.aes = list(alpha = 1, size = 4)))
so your code would read something like:
ggplot(data, aes(x=vx, y=vy, shape=Cluster)) +
geom_text(aes(label=PicNr, color=Cluster), size =6, fontface = "bold", check_overlap = T, show.legend=F) +
geom_point(aes(color=Cluster), alpha = 0)+
theme_bw(base_size = 20)+
theme(legend.position="top")+
guides(color = guide_legend(override.aes = list(alpha = 1, size = 4)))
Created on 2018-08-18 by the reprex package (v0.2.0).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments