shaded area with polygon

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

shaded area with polygon

L... L...
Dear All, I know this is a trivial question .. but .. I want to shade the area between 2 curves. For example:

x <- 1:10

y <- 3*x^2 + 2*x + 7

z <- y + 100

plot(x, y,  type = 'l')

lines(x, z)

I can not understand polygon.

I tried

polygon(cbind(c(min(x), x, max(x)), c(min(y), z, max(y))), col="#00CC66")

But I do not return what I want.

Thank you very much

ML



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: shaded area with polygon

R help mailing list-2
Does
  polygon(c(x,rev(x)), c(y, rev(z)), col="orange")
do what you want?

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Jun 11, 2018 at 12:35 PM, L... L... <[hidden email]> wrote:

> Dear All, I know this is a trivial question .. but .. I want to shade the
> area between 2 curves. For example:
>
> x <- 1:10
>
> y <- 3*x^2 + 2*x + 7
>
> z <- y + 100
>
> plot(x, y,  type = 'l')
>
> lines(x, z)
>
> I can not understand polygon.
>
> I tried
>
> polygon(cbind(c(min(x), x, max(x)), c(min(y), z, max(y))), col="#00CC66")
>
> But I do not return what I want.
>
> Thank you very much
>
> ML
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.