I'm trying to plot some data with ordered factors in R, more specifically trying to plot several data points per factor. For better readability, I'm trying to plot the names with text
, then color them for better readability.
I set it up like so:
df[['category']]=ordered(df[['category']], levels=c("nm", "nw", "xw", "xm"))
Which gives me this output, which looks good to me:
[1] xw xm nw nm
Levels: nm < nw < xw < xm
I plot it like this:
text(xval, temp, label= df[['category']], col=seq(1,4))
(Where xval and temp vary depending on input; the seq in col
is supposed to color it). But then my plot does not look right (xw takes the place of nm).
Printing the output of df[['category']]
gives me this:
3 4 2 1
And I don't know how to read that; what does this mean?
Is this the way it needs to look or does this tell me what's wrong with my plot?
I'm sorry I can't show my plots here but this is research with data that are not mine. Any help is much appreciated!