-1

I hope that with this edition my question improve and it could be reproducible.

Imagine I have this data, in which X are certain values of a measure and Y are 4 groups, each one representing forage quality. I could used letters for the forage quality, as L (low), M (medium), H (high) and VH (very high), but I use the values because I want the boxplots to be drawn in the x-axis at this real points, 4.8, 13, 18.02 and 21, and not with the same distance between them.

    Data <- data.frame(X = sample(1:12),
    Y = sample(rep(c(4.8, 13, 18.02, 21), each=3)))

I use this simple code to draw the boxplot

    boxplot(Data$X ~ Data$Y)

How could I scale the boxplots along the x-axis? Should I use any graphic library instead?

Thanks

TeSeA
  • 55
  • 6
  • 5
    You need to supply [a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including code and some data. – Thomas Aug 02 '14 at 18:21
  • Thank you @Thomas, I've just plot a boxplot with the code 'boxplot(animal$X ~ animals$Y)', where X are 60 samples and Y four groups. This groups correspond to 4 differents values (4.86, 9.81, 13.05 and 23) of crude protein. Like I've said, I would like them (boxplots) to appear with the real scale of the four groups, and not like they were 0,5,10,15 (with the same distance between them in the x-axis). The website don't allow me to put the image because I've just registered on the web. – TeSeA Aug 02 '14 at 19:44
  • Did you read anything on the page I linked to or read anything about how to ask questions on this site? We cannot help you without seeing the *exact* code you are using. – Thomas Aug 02 '14 at 19:46

1 Answers1

2

You want to use the at argument to boxplot to specify where the boxes are drawn. Specifically:

boxplot(Data$X ~ Data$Y, at = sort(unique(Data$Y)))

enter image description here

Thomas
  • 43,637
  • 12
  • 109
  • 140