Changing order of legend labels in ggord

Viewed 69

I am plotting the outcome of a linear discriminant analysis using the ggord function. ggord also provides a legend, which lists the legend labels in alphabetical order. Does anyone know how I can change the order of the legend labels?

I know that for general plots one would change the sequence of the factors in the input data set using factors(x,levels=c()), but I suppose that doesn't work in my case since ggord reads the legend labels from the lda model output.

ggord(ldamod2, av.nonna2$state,size=2,cols=c(high.col,low.col,medium.col), arrow=0.2,txt=3,vec_lab=text.list2, grp_title="Emission State", max.overlaps = 8, repel=TRUE, ext=1) + 
          theme(legend.position = 'right')+
          labs(title = "Nov 2018 - Dec 2019")+ theme(plot.title = element_text(hjust = 0.5)) +
          annotate("text", x=-3.1, y=3.7, label= "b",col="grey30") 

enter image description here

0 Answers
Related