Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8325

Re: Filling area between curves

From "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Filling area between curves
Date 2012-02-04 11:28 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jgj4pk$mt2$1@smc.vnet.net> (permalink)
References <jgg1fq$bpm$1@smc.vnet.net>

Show all headers | View raw


On Fri, 03 Feb 2012 07:14:02 -0000, Elaine Ritter <eyeninei9@gmail.com>  
wrote:

> I have 3 curves, and I want to fill one of the areas that they bound.
> The equations are
> F[x] = -1 + 4 x - x^2
> G[x] := x - 2
> H[x] := 2 - x
> and I want to fill the region that I shaded in this picture:
> http://i.imgur.com/X2urH.png
>
> I've been trying to figure this out on my own, but to no avail. How do
> I do this?
>

Please, try to copy the code in your post from Mathematica rather than  
re-typing it. There are errors in all three of the definitions above.

Filling regions can be defined between a pair of curves, but not bounded  
by several curves, so you might try ending the line segments at the  
horizontal axis and filling the pieces separately as follows:

F[x_] := -1 + 4 x - x^2;
G[x_] := Piecewise[{{x - 2, x >= 2}, {Indeterminate, True}}];
H[x_] := Piecewise[{{2 - x, x <= 2}, {Indeterminate, True}}];

Plot[
  {F[x], G[x], H[x]}, {x, 0, 5},
  PlotRange -> {0, 3},
  Filling -> {
   1 -> {{2}, {None, Red}},
   1 -> {{3}, {None, Red}}
  }
]


Or, you can close the region another way:

F[x_] := -1 + 4 x - x^2;
G[x_] := x - 2;
H[x_] := 2 - x;
m[x_] := Max[G[x], H[x]];

Plot[
  {F[x], G[x], H[x], m[x]}, {x, 0, 5},
  PlotStyle -> {Automatic, Automatic, Automatic, None},
  PlotRange -> {0, 3},
  Filling -> {
   1 -> {{4}, {None, Automatic}}
  }
]

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Filling area between curves Elaine Ritter <eyeninei9@gmail.com> - 2012-02-03 07:14 +0000
  Re: Filling area between curves "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-04 11:28 +0000
  Re: Filling area between curves David Reiss <dbreiss@gmail.com> - 2012-02-04 11:29 +0000

csiph-web