You can set the order for a "factor" class variable by setting the levels
argument, be aware that even if your variable was not a factor already, when mapping categorical variables to certain aesthetics they get coerced into factors automatically, so to keep the desired order you might want to do it explicitly.
levels
an optional vector of the unique values (as character strings) that
x
might have taken. The default is the unique set of values taken byas.character(x)
, sorted into increasing order ofx
. Note that this set can be specified as smaller thansort(unique(x))
If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.