Scale_shape_manual ggplot2 problem. How to assign shapes to two different groups and have them start from the same shape

Hi all,

I'm a graduate student and I'm trying to get a specific code in ggplot2 to work properly. Basically, my project involves studying the distribution of clones in a cattails of which there are 3 species in almost all the populations. The code below is for one population. For the most part it works, it colour codes the two taxa differently and assigns each clone it's own "letter". However, when I run the code it does not start from the same point for each of the taxa. For instance, the first clone type (same genotype) starts with the letter "A" (#65on the scale_shape_table) and each is assigned up to letter "Z'" (#90 on the scale_shape_table). Ideally, I'd like it to start from the same letter for the next taxa. But it just seems to randomly assign letters. Furthermore, if the number of clones exceeds 26, and I need to add more letters. Would I just change it to (65:90, 97:122) if I just want more letters?
I'd appreciate any input. Thanks in advance

x.COW<-datCOW$x1 #assigns x values to a variable called 'x.COW'
y.COW<-datCOW$y1 # same as above but with y values

ggplot(datCOW, aes(x.COW, y.COW))+ #uses data 'COW' in ggplot with x.COW and y.WCOW as variables to plot
  geom_point(aes(colour=taxa, shape=COWMLG, size=3))+ # assigns colours and shapes of points to species and clone, respectively
  guides(size=FALSE)+ #removes legend for size (I only want legend for colour)
  scale_colour_manual(values=c("green", "orange"))+ #manually sets colours to green and orange; 
  #assigns alphabetically - Tlat is green, Txg orange
  scale_shape_manual(values=c(97:122), guide=FALSE)+ #manually sets shapes (by number), #removes legend for shape (I only want legend for colour)
  theme_bw()+theme(panel.grid.major=element_line(colour="white"))+
  theme(panel.grid.minor=element_line(colour="white"))+ # lines 20 and 21 remove default grey background
  xlab("m")+ #labels x axis with 'm'
  ylab("m")+ #labels y axis with 'm'
  ggtitle("EDD, Clone threshold 0")+ #gives plot title
  theme(plot.title=element_text(hjust=0.5)) # centres plot title (default is left-justified)

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.