Stephan Holl
2002-Jul-21 12:47 UTC
[R] boxplot(): formating median in another linethickness?
Dear guRus, I want to do some boxplots, but the median sould appear in another line-thickness and another color. I do not know, what to do in order to realise my wishes. Sorry for that question, but I am new to R. cheers steph -- Linux: the operating system with a CLUE... Command Line User Environment. -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020721/90fbdc87/attachment.bin
Uwe Ligges
2002-Jul-21 14:04 UTC
[R] boxplot(): formating median in another linethickness?
Stephan Holl wrote:> > Dear guRus, > I want to do some boxplots, but the median sould appear in another > line-thickness and another color. > I do not know, what to do in order to realise my wishes. > > Sorry for that question, but I am new to R.You have to adapt the function bxp() for your purposes: If you use fix(bxp), you can change the color in lines 27 and 38. It's a nice programming exercise to add an argument to boxplot() that colors the median differently from the other borders (and thus passes the argument to bxp() appropriately). Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Marc Schwartz
2002-Jul-21 15:00 UTC
[R] boxplot(): formating median in another linethickness?
Stephan Holl wrote:> > Dear guRus, > I want to do some boxplots, but the median should appear in another > line-thickness and another color. > I do not know, what to do in order to realise my wishes. > > Sorry for that question, but I am new to R.There are a couple of approaches: 1. As Uwe has pointed out, you could modify the code for bxp(). OR 2. When you call the boxplot() function, call it with the following syntax:> P <- boxplot("...")Where the "..." is your specific set of arguments. This assigns the results of the boxplot call to "P", which is a list of values that contains plotting summary information for your data. You can use something other than P of course if you wish. Type in "P" at the command line (without the quotes) so you can see the contents of the list. See "Value" in the boxplot help file text (?boxplot) for a description of the contents of the list. After plotting your data, use one of the two following calls depending upon whether you are plotting your graphic vertically or horizontally: Horizontal: segments(P$stats[3, ], 1:length(P$n) - 0.4, P$stats[3, ], 1:length(P$n) + 0.4, lwd = 3, col = "YourColor") Vertical: segments(1:length(P$n) - 0.4, P$stats[3, ], 1:length(P$n) + 0.4, P$stats[3, ], lwd = 3, col = "YourColor") The above calls will need to be modified depending upon whether you have modified the width, boxwex or varwidth settings and if you are drawing notches. The "0.4" values that I use above are for the default "width" of 1, a default "boxwex" of 0.8, a default varwidth = FALSE and with no notches being drawn. Thus, the 0.4 is the result of (1 * 0.8) / 2, which is half the default box width. If you are drawing notches, the default notch width adjustment is 0.5, so further multiply the 0.4 I have above by 0.5, so it becomes 0.2. In R, the box centers are integer values equal to the number of groups in your data. Thus the "1:length(P$n)" values define the box centers, either on the x or y axis depending upon the orientation of your plot. This presumes that you have not modified the default values with the "at = " argument. The P$Stats[3, ] data is the row vector of median values, one for each group from the list. The result of the segments call then draws a series of median lines with the line width that your define by the "lwd =" parameter and the color that you define with the "col = " parameter. Which approach you take depends upon how complex you are making the boxplot. If you are doing a straight-forward plot, then option 2 I think would be the easiest and you can use the segments calls as I have them above. If you are doing some more complex width or other location adjustments, then the first option suggested by Uwe would be easier, since the required code for making the various adjustments is already done for you. HTH. Marc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Stephan Holl
2002-Jul-21 15:55 UTC
[R] boxplot(): formating median in another linethickness?
Dear MArc, On Sun, 21 Jul 2002 10:00:57 -0500, "Marc Schwartz" <mschwartz at medanalytics.com> wrote:> Which approach you take depends upon how complex you are making the > boxplot. If you are doing a straight-forward plot, then option 2 I > think would be the easiest and you can use the segments calls as I > have them above.Thank you very much for your detailed help! I am just doing strait-forward boxplots, and number 2 is just what I wanted. R is so adjustable, but you have to know how! ;-) cheers steph -- Linux: the operating system with a CLUE... Command Line User Environment. -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020721/3d0e5e49/attachment.bin