0

I am trying to make beeswarm and boxplot graphs of my data, but beeswarm is putting the categorical variables in alphabetical order when I would like them in order of treatment.

iMono <- beeswarm(iMono ~ Treatment, data=MyeloidLiver, ylab = "% Inflammatory",
         log = FALSE, pch=16, main = '% Inflammatory Monocytes v Treatment',
         col = rainbow(4), cex.axis = 1, cex = 1) +
  bxplot(iMono ~ Treatment, data=MyeloidLiver, add=TRUE)

I have tried using levels = c() and labels = c() but levels is not a graphical parameter for beeswarm and labels changes the labels without reordering the corresponding data.

  • 2
    If your variable is not already a factor, make it a factor and put the `levels=` in the order you like (levels= and labels= are for the factor() functions, not plotting functions). Or use `reorder()` to change the levels. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jul 08 '21 at 01:03
  • 1
    I wonder how many duplicates there are to this question? At least 10, probably 50+ and maybe 100+. – IRTFM Jul 08 '21 at 01:26

0 Answers0