[R] [R ]Plot a colored rectangle under the points of a graph

R. Michael Weylandt michael.weylandt at gmail.com
Sat Oct 8 19:04:47 CEST 2011


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.
>



More information about the R-help mailing list