Re: Small question about Filling between two functions in a determined interval
- To: mathgroup at smc.vnet.net
- Subject: [mg94439] Re: Small question about Filling between two functions in a determined interval
- From: Peter Breitfeld <phbrf at t-online.de>
- Date: Sun, 14 Dec 2008 07:32:20 -0500 (EST)
- References: <ghnfhr$nkc$1@smc.vnet.net>
Felipe Mannshardt schrieb:
> Hello,
>
> 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 ) ?
>
> Thanks !
>
> PS: Between, what is the most used way of pasting text from Mathematica in
> here ? (Plain Text ? LATEX ? ??? )
>
>
> Thanks !!!
>
I use the following function:
Options[FlaechenPlot]=Union[Options[Plot],Options[Graphics]];
SetOptions[FlaechenPlot,Filling->Axis];
FlaechenPlot[f_List,{x_,xmin_,xmax_},{fmin_,fmax_},opts:OptionsPattern[]]:=
Module[{kp,fp,optP,optF,optG,fill},
fill=OptionValue[Filling];
optF=FilterRules[Flatten[{opts}],Options[Plot]];
optP=DeleteCases[optF,Filling->_];
optG=FilterRules[Flatten[{opts}],Options[Graphics]];
kp=Plot[f,{x,xmin,xmax}, Evaluate[optP]];
fp=Plot[f,{x,fmin,fmax}, Filling->fill, Evaluate[optF]];
Show[kp,fp,Evaluate[optG]]
];
FlaechenPlot[f_List,{x_,xmin_,xmax_},opt:OptionsPattern[]]:=
FlaechenPlot[f,{x,xmin,xmax},{xmin,xmax},opt];
FlaechenPlot[f_,{x_,xmin_,xmax_},{fmin_,fmax_},opt:OptionsPattern[]]:=
FlaechenPlot[{f},{x,xmin,xmax},{fmin,fmax},opt];
FlaechenPlot[f_,{x_,xmin_,xmax_},opt:OptionsPattern[]]:=
FlaechenPlot[{f},{x,xmin,xmax},{xmin,xmax},opt];
Then try:
FlaechenPlot[{u[x], k[x]}, {x, -2, 10}, {2, 8}, Filling -> {1 -> {2}}]
Gruss Peter
--
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de