Re: graphing inequalities
- To: mathgroup at smc.vnet.net
- Subject: [mg15908] Re: graphing inequalities
- From: "Peltio" <pelt.ioNOS at PAMiol.it>
- Date: Wed, 17 Feb 1999 23:33:48 -0500
- Organization: Peltio Inc.
- References: <7a28l3$1nq@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2/8/99 4:53:24 AM, rubindl at aol.com writes:
>How do I plat an inequality, such as y - x > 6 in Mathematica? I'd like
>to end up with a dashed line and the region above the line shaded.
>
Daniel,
Here's a little shell that lets you use FilledPlot to do what you want (the
options are to preserve the ability not to display the graph: they are a
little messy I know but...).
Needs["Graphics`FilledPlot`"]
MidFilledPlot[{f_>g_},{x_,xmin_,xmax_},opts___]:=
Module[
{p1,p2},
p1=FilledPlot[{If[f>g,f,g],g},{x,xmin,xmax},DisplayFunction->Identity,opts];
p2=Plot[f,{x,xmin,xmax},DisplayFunction->Identity];
Show[p1,p2,
DisplayFunction->(DisplayFunction
/. {opts}/.DisplayFunction->$DisplayFunction )]
]
MidFilledPlot[{f_<g_},{x_,xmin_,xmax_},opts___]:=
Module[
{p1,p2},
p1=FilledPlot[{If[g>f,g,f],f},{x,xmin,xmax},DisplayFunction->Identity,opts];
p2=Plot[g,{x,xmin,xmax},DisplayFunction->Identity];
Show[p1,p2,
DisplayFunction->(DisplayFunction
/. {opts}/.DisplayFunction->$DisplayFunction )]
]
Just drop in the inequality and it should work.
f=3Sin[x];
g=.2x^3-.2x+1;
Block[{$DisplayFunction=Identity},
p1=MidFilledPlot[{f>g},{x,-4,4}];
p2=MidFilledPlot[{f<g},{x,-4,4},Fills->Hue[.8]];
]
Show[GraphicsArray[{p1,p2}]]
Regards,
Peltio (peltioNOSPAM at usa.net)