Heverkuhn Heverkuhn
2011-Oct-08 16:53 UTC
[R] [R ]Plot a colored rectangle under the points of a graph
Hello everyone, if I have: x=1:10 y=1:10 plot(x,y) and I plot a rectangle rect(4,0,6,11, col=5) it covers the points of the graph. Is there a way to draw the rectangle under the points? I was thinking the a solution could be draw an empty plot then draw the rectangle and after the points, but it did not work. Any idea? thanks for your help H. [[alternative HTML version deleted]]
R. Michael Weylandt
2011-Oct-08 17:04 UTC
[R] [R ]Plot a colored rectangle under the points of a graph
My guess is that your intuition was correct, but you probably executed it incorrectly. Plot (usually) calls a new plotting window; if you want to add to a window that's already open, you need to use a specialized command like points, lines, etc. Try this x <- y <- 1:10 plot(x,y,type="n"); rect(4,0,6,11,col=5); points(x,y) Hope this helps, Michael Weylandt On Sat, Oct 8, 2011 at 12:53 PM, Heverkuhn Heverkuhn <heverkuhn at gmail.com> wrote:> Hello everyone, > if I have: > x=1:10 > y=1:10 > plot(x,y) > > and I plot a rectangle > rect(4,0,6,11, col=5) > > it covers the points of the graph. > Is there a way to draw the rectangle under the points? > I was thinking the a solution could be draw an empty plot > then draw the rectangle and after the points, > but it did not work. > Any idea? > > thanks for your help > H. > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
Robert Baer
2011-Oct-08 17:43 UTC
[R] [R ]Plot a colored rectangle under the points of a graph
This is what you tried? What doesn't work? x=1:10 y=1:10 plot(x,y, type='n') rect(4,0,6,11, col=5) points(x,y) _______________ Hello everyone, if I have: x=1:10 y=1:10 plot(x,y) and I plot a rectangle rect(4,0,6,11, col=5) it covers the points of the graph. Is there a way to draw the rectangle under the points? I was thinking the a solution could be draw an empty plot then draw the rectangle and after the points, but it did not work. Any idea? thanks for your help H. [[alternative HTML version deleted]] ______________________________________________ R-help at 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. ------------------------------------------ Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A. T. Still University of Health Sciences 800 W. Jefferson St. Kirksville, MO 63501 660-626-2322 FAX 660-626-2965