0

I have the following data frame in R and have currently the following ggplot.

means.df <- data.frame(means,columnnames,coltype)
p1 <- ggplot(means.df, aes(x=means,y=columnnames,color=factor(coltype) )) +
  geom_point() + scale_color_manual(values=c("blue", "red", "black"))   

Now my plot is colored correctly based on the factor 'coltype', but is still ordered alphatbetically. I want to change the order based on the factor 'coltype', how should I do this?

Turin
  • 1
  • 1
    It's not clear what order you expect, but you need to change the factor levels. You can do that directly in the `ggplot` call, for example, `factor(coltype, levels = c("coltype1","coltype2","coltype3"))`. Replace `"coltype1"` with your actual column types. – Ian Campbell Jun 08 '21 at 14:03

0 Answers0