How to add grid lines at specific position to a plot? Hi all, [Disclaimer: I have done extensive and intensive searching on Google and asked around but couldn't find a solution to this problem. Please help me instead of just pointing out how simple and stupid my question is. God bless good folks! Thanks!] This is a headache for me and I have been struggling with this for a while. With an existing plot, how can I add a horizontal grid line at vertical location 0 (just need 1 grid line)... I can certainly draw such a line myself using "lines". However, that will impact my legends because that also counts as a line. But we wouldn't want a grid line to be counted as a line... Could anybody please help me? Thanks! [[alternative HTML version deleted]]
Sarah Goslee
2012-Mar-15 17:30 UTC
[R] How to add grid lines at specific position to a plot?
abline(h=0) On Thu, Mar 15, 2012 at 1:05 PM, Michael <comtech.usa at gmail.com> wrote:> How to add grid lines at specific position to a plot? > > Hi all, > > [Disclaimer: I have done extensive and intensive searching on Google and > asked around but couldn't find a solution to this problem. > Please help me instead of just pointing out how simple and stupid my > question is. God bless good folks! Thanks!] > > This is a headache for me and I have been struggling with this for a while. > > With an existing plot, how can I add a horizontal grid line at vertical > location 0 (just need 1 grid line)... > > I can certainly draw such a line myself using "lines". > > However, that will impact my legends because that also counts as a line. > But we wouldn't want a grid line to be counted as a line... > > Could anybody please help me? > > Thanks! >-- Sarah Goslee http://www.functionaldiversity.org
Luke Miller
2012-Mar-15 17:33 UTC
[R] How to add grid lines at specific position to a plot?
abline(h = 0) will do what you want. abline(h = c(0,1,2)) would draw additional lines at y = 1 and y = 2. abline(v = 0) would draw a vertical line at x = 0. All of these lines will be plotted on top of whatever you plotted previously, so you may have to replot your points or lines so that they're not obscured by the ablines. On Thu, Mar 15, 2012 at 10:05 AM, Michael <comtech.usa@gmail.com> wrote:> How to add grid lines at specific position to a plot? > > Hi all, > > [Disclaimer: I have done extensive and intensive searching on Google and > asked around but couldn't find a solution to this problem. > Please help me instead of just pointing out how simple and stupid my > question is. God bless good folks! Thanks!] > > This is a headache for me and I have been struggling with this for a while. > > With an existing plot, how can I add a horizontal grid line at vertical > location 0 (just need 1 grid line)... > > I can certainly draw such a line myself using "lines". > > However, that will impact my legends because that also counts as a line. > But we wouldn't want a grid line to be counted as a line... > > Could anybody please help me? > > Thanks! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- ___________________________ Luke Miller Postdoctoral Researcher Hopkins Marine Station, Stanford University 120 Ocean View Blvd Pacific Grove, CA 93950 831-655-6208 [[alternative HTML version deleted]]