[R] Any ideas on how to add a dotted line to a box plot to indicate a specific value?

Paul Murrell p.murrell at auckland.ac.nz
Thu May 26 01:54:38 CEST 2005


Hi


BJ wrote:
> Basically, i want to create a boxplot from population data, with a solid 
> line for the median, and then a dotted line for a specific persons 
> value. Is there a way to artificially introduce another line or mark of 
> some kind in a box plot? Thanks again for all of yoru help. Hopefully 
> soon I wont have to keep bugging you all. ~Erithid :-p


Do you mean something like this ... ?

with(ToothGrowth,
      {
        boxplot(len ~ supp)
        # boxplots horizontally centred at 1 and 2
        # 0.6, 1.4 come from default boxwex of 0.8
        #   (1 +/- boxwex/2)
        # 18 I made up
        lines(c(0.6, 1.4), c(18, 18),
              lty="dashed", col="red")
      })

Paul
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list