I have made a graph where the points are marked with different colors (depending on the parameter a), on the graph I need to save the names of the samples (points). At the same time, in the notation of the chart legend, I need squares indicating the color. But instead, in the notation of the legend, I get the "a" icon of the right colors, which looks rather ridiculous.

How can I change the "a" in the legend to squares/circles so that the names of points of different colors are preserved on the chart?

Code for the graph:

ggplot(data=mds.data, aes(x=X, y=Y,label=Sample, color=a)) +
  geom_text() +
  theme_bw() +
  xlab(paste("PCoA1 -", mds.var.per[1], "%", sep="")) +
  ylab(paste("PCoA2 -", mds.var.per[2], "%", sep="")) +
  ggtitle("PCoA plot using dtw-distance")+
  scale_color_manual(name="a=",labels=c("0.25", "0.5","0.75","1"),values ​​= c("red3","forestgreen","darkblue","orange") )

Vector content eh? Please provide reproducible code with data.

black_paladin2022-02-15 04:45:14

I accidentally created two accounts, how do I merge them?

aleksandr barakin2022-02-14 10:10:32

@black_paladin changed the code to a simpler one to show what the problem is.

Диана2022-02-14 12:43:48