How to manually plot Box and Whisker graph?
boxplot, plot, r
Solution
Use `bxp` to make a boxplot from a five-number summary.
Does this do the sort of thing you want?
testdata=data.frame(R1=c(0,5,3,2,4),R2=c(1,7,3,2.8,6))
o=c(1,5,3,4,2) # the rows in increasing order
bxp.data=list(stats=data.matrix(testdata[o,]),n=rep(1,ncol(testdata)))
# the n=... parameter doesn't affect the plot, but it still needs to be there
bxp(bxp.data)
You can use standard graphical parameters (see `help(par)`) to label the axes and make it look pretty.
(Note: row numbers are off by one because the question was edited after I posted this answer. I'll leave the answer as is so that it matches the first two comments.)
Problem
Box and Whisker graph displays the following information: max, min, mean, 75th percentile, 25th percentile. If I have these information, can I plot the corresponding B&W graph? I have this data frame called TP.df: ``` pb1 ag1 pb2 ag2 pb3 ag3 Nb 498 498 85 85 68 68 Min 0 0 0 0 0 0 Max 1.72 461 2.641 260.8 0.3 144 Mean 0.06 19.2 0.15 35.35 0.02 9.11 75_p 0.06 20 0.08 33 0.02 8 25_p 0.01 10 0 14 0.01 4 ``` file: ``` ,pb1,ag1,pb2,ag2,pb3,ag3 Nb,498,498,85,85,68,68 Min,0,0,0,0,0,0 Max,1.72,461,2.641,260.8,0.3,144 Mean,0.06,19.2,0.15,35.35,0.02,9.11 75_p,0.06,20,0.08,33,0.02,8 25_p,0.01,10,0,14,0.01,4 ``` How can I have the corresponding Box and Whisker graph: - it must show 6 boxes - x axis : `pb1`, `ag1`, `pb2`, `ag2`, `pb3`, `ag3` - y axis : `0` to `max(TP.df[Max,])`