[R] shaded area between a curve and a circle
Uwe Ligges
||gge@ @end|ng |rom @t@t|@t|k@tu-dortmund@de
Sun Oct 23 14:47:10 CEST 2022
The points on your density curve can be written as (x, f(x)) - well, if
you had not divided by its max value which I do not understand why.
Now you simply need to find out which of these points have a distance of
the circle's radius to the point (0,0).
Hmmm, your "circle" has a radius of 2 in x direction but less in y
direction? So this is not a circle but an ellipse given the coordinate
system used?
Assuming you actually want to draw a circle of radius r, then I would
simply solve Pythagoras' equation, i.e. sqrt(x^2 + f(x)^2) == r
e.g. via uniroot().
But first you need to find out what you actually want to do.
Best,
Uwe Ligges
On 22.10.2022 21:05, L... L... wrote:
> 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]]
>
> ______________________________________________
> R-help using 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.
More information about the R-help
mailing list