[R-sig-teaching] Shading the solution of quadratic inequality

R. Michael Weylandt michael.weylandt at gmail.com
Thu Feb 16 15:42:18 CET 2012


You should probably say more about which graphics engine you are
using, but here's a start:

curve(x^2-4, from = -3, to = 3)
x <- seq(-3, 3, length.out = 200)
polygon(c(x, rev(x)), c(x^2-4, rep(Inf, length(x))), col = 2)

The red is a little "oppressive" so I'd try to add transparency if
your device supports it. Adding a shade above/below argument to curve
based on the same principles might be a fun exercise too...

Michael

On Thu, Feb 16, 2012 at 9:13 AM, AbouEl-Makarim Aboueissa
<aaboueissa at usm.maine.edu> wrote:
> Dear all R Users:
>
> How can I shade the solution (-Inf,-2) or (2,Inf) of the inequality -x^2+4<0 within the curve of f(x)=-x^2+4.
>
> and
>
> the solution (-Inf,-2)or(2,Inf) of the inequality x^2-4>0 within the curve of
> f(x)=x^2-4.
>
>
> with many thanks
>
> abou
>
>
> ==========================
> AbouEl-Makarim Aboueissa, Ph.D.
> Associate Professor of Statistics
> Graduate Program Coordinator
> Department of Mathematics & Statistics
> University of Southern Maine
> 96 Falmouth Street
> P.O. Box 9300
> Portland, ME 04104-9300
> USA
>
>
> Tel: (207) 228-8389
> Fax: (207) 780-5607
> Email: aaboueissa at usm.maine.edu
>          aboueiss at yahoo.com
>
> Office: 301C Payson Smith
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching



More information about the R-sig-teaching mailing list