MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Small question about Filling between two functions in a determined interval

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94390] Re: Small question about Filling between two functions in a determined interval
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 11 Dec 2008 07:27:54 -0500 (EST)
  • References: <ghnfhr$nkc$1@smc.vnet.net> <493F7351.1070802@gmail.com>

Felipe Mannshardt wrote:

> i have been trying to get this working, without much success.
>
> What i want, is to fill an area between two functions, but only between the
> interval from x=2 to x=8
>
> I have,
>
> u[x_]:=48x
> k[x_]:=2x^3-18x^2+60x+32
>
> Plot[{k[x], u[x]}, {x, -2, 10}, Filling -> {1 -> {2}}]
>
> It draws (fills) every area between k(x) and u(x).
>
> How can i tell Mathematica to just fill between a determined interval (x
> Axis : 2->8 ) ?

Hi Felipe,

As far as I know, there exist no option for the plot command that
restricts the filling to a specific x-axis interval. Depending on the
functions to be plotted and the required interval, you could use the
following form for the Filling option,

 Filling -> {1 -> {{2}, {Orange, White}}}

or you could build a first plot over the full range of value without
any filling, a second plot over the desired interval with filling, and
show both plots together. Here are some examples of both solutions:

 u[x_] := 48 x
 k[x_] := 2 x^3 - 18 x^2 + 60 x + 32

 Plot[{k[x], u[x]}, {x, -2, 10},
  Filling -> {1 -> {{2}, {Orange, White}}}]

 Plot[{k[x], u[x]}, {x, -2, 10},
  Filling -> {1 -> {{2}, {Automatic, None}}}]

 p1 = Plot[{k[x], u[x]}, {x, -2, 10}];
 p2 = Plot[{k[x], u[x]}, {x, 2, 8},
    Filling -> {1 -> {{2}, {Orange, White}}}];
 Show[p1, p2]

> Thanks !
>
> PS: Between, what is the most used way of pasting text from Mathematica in
> here  ? (Plain Text ? LATEX ? ??? )

Without any doubt, I strongly believe that *InputForm* is the winner!

Select the cell(s) you want to include in your email, then within the
*Cell* menu select either *Convert To* or *Display As* and choose
*InputForm*. Finally, copy and paste as usual.


Hope this helps,
-- Jean-Marc


  • Prev by Date: Re: Clever way to manipulate lists
  • Next by Date: Re: Clever way to manipulate lists
  • Previous by thread: RE: Re: Small question about Filling between two functions in a determined interval
  • Next by thread: Re: Small question about Filling between two functions in a determined interval