Re: [R] Adding Lines to Plot

From: Greg Snow <Greg.Snow_at_intermountainmail.org>
Date: Tue 11 Jul 2006 - 05:02:22 EST


 There are a couple of different options that you can try (each generalize a bit differently to other situations).

If you just want lines at the tick marks to go the entire width (and be generated automatically to match the labels), then look at ?par and look at 'tck', you can use this in the barplot call, or in a call to axis after the fact. If you want the bars on top then just issue another call to barplot with add=T.

See abline and the h= option for drawing lines across the entire width.

See par and the 'usr' entry for how to find the user coordinates of the edges of the plot (for adding lines by hand).

See the cnvrt.coords function in the TeachingDemos package for more general conversions between coordinate systems (you can use this to draw a line from half way across to the edge, or other aritrary locations, probably overkill for your problem).

The return value for barplot gives the center positions of the bars (the heights match the data you input to barplot), see the first example in the help for barplot.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow@intermountainmail.org
(801) 408-8111
 

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of justin rapp
Sent: Saturday, July 08, 2006 1:05 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Adding Lines to Plot

This seems like a question that I should be able to answer on my own but
after looking at the documentation I cannot seem to find the correct
method.

How do I add lines to a bar plot that extend from the vertical axis?
For example, my vertical axis is numbered in increments of 10 and I
would like these to go across the whole graph.

Also, is there a way to have R label the value of each bar so that I
know the value of each factor that is being plotted?

Thanks in advance.

jdr


______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________
R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jul 11 05:11:22 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 11 Jul 2006 - 06:16:20 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.