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]]
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... <mar.lamack at hotmail.com> 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]] > > ______________________________________________ > R-help at r-project.org 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]]
Dear, I have a picture in which I draw a circle over the standard normal curve. See below the lines used to draw the figure. The figure is ok, but my problem is: How to shade the areas A, B, C, D, E and F? I know I have to find the points of intersection but I don't know how to find them. Suggestions will be welcome. library(plotrix) x <- seq(-3.0, 3.0, 0.01) fy <- dnorm(x) fy <- fy / max(fy) x11() plot(x, fy, ylim = c(-1, 1), col = "white", lwd = 1.5, xlim = c(-3, 3), lty = 1) draw.circle(0.0, 0.0, 2.00, border = 'blue', lty = 1, lwd = 0.8) lines(x, fy, type = 'l', ylim = c(-1,1), col = 'red', ) lines(x,-fy, type = 'l', ylim = c(-1,1), col = 'red') text( 0.0, 0.90, "A"); text( 0.0,-0.90, "B") text(-1.8, 0.25, "C"); text( 1.8, 0.25, "D") text(-1.8,-0.25, "E"); text( 1.8,-0.25, "F") Best regards ML ________________________________ [[alternative HTML version deleted]]