[Date Index]
[Thread Index]
[Author Index]
# Re: ColorFunction and/or ColorOutput - mkdk
*To*: mathgroup@smc.vnet.net
*Subject*: [mg10789] Re: ColorFunction and/or ColorOutput - mkdk
*From*: Paul Abbott <paul@physics.uwa.edu.au>
*Date*: Thu, 5 Feb 1998 00:58:33 -0500
*Organization*: University of Western Australia
*References*: <6b3one$rpi@smc.vnet.net>
decker, mark a wrote:
> I would also like to clean up all the errors I am generating, by either
> defining my function in a different way OR turning off a few of the
> error codes. I realize there are undefined regions in the plot.
>
> Here it is. It was simple enough I didn't even define functions.
>
> cond = {alpha -> Pi/6, lambda -> 2.15, Ei -> Ep - Es}
>
> R = lambda Ei Sqrt[ 1 - (Ep/Ei) Sin[alpha]^2 ]
>
> DensityPlot[R /. cond, {Ep, 0, 6}, {Es,0,4.5}, Mesh->False,
> PlotRange->{0,1}, PlotPoints->100 ]
>
> What I would like to do is the following:
>
> R<0 be black
>
> R=0 some bright color.
>
> 0<R<1 be shaded where R~0 is dark and R~1 is light.
>
> R>1 be white
>
> R undefined be some other color.
How about
color[x_]:= Which[x < 0, GrayLevel[1],x == 5, Hue[1],0<x<1, Hue[x],
True, GrayLevel[0]]
Off[Power::infy, DensityPlot::plnr, Infinity::indet,
DensityGraphics::zval]
DensityPlot[Evaluate[R /. cond], {Ep, 0, 6}, {Es,0,4.5},
Mesh->False, PlotPoints->100, ColorFunction->color]
You can avoid some of the problems you're encountering by introducing a
function, f, like
f[Ep_, Es_, alpha_, lambda_] =
lambda Ei Sqrt[1 - Ep/Ei Sin[alpha]^2] /. Ei -> Ep - Es
When Ep==Es there is a problem. Taking a Limit avoids this:
f[Ep_, Ep_, alpha_, lambda_] = Limit[f[Ep, Es, alpha, lambda], Ep ->
Es]
DensityPlot[f[Ep, Es, Pi/6, 2.15], {Ep, 0, 6}, {Es, 0, 4.5},
Mesh -> False, PlotPoints->100, ColorFunction->color];
Cheers,
Paul
____________________________________________________________________
Paul Abbott Phone: +61-8-9380-2734
Department of Physics Fax: +61-8-9380-1014
The University of Western Australia Nedlands WA 6907
mailto:paul@physics.uwa.edu.au AUSTRALIA
http://www.pd.uwa.edu.au/~paul
God IS a weakly left-handed dice player
____________________________________________________________________
Prev by Date:
**Re: help with Mathematica 3.0 'features' under NT**
Next by Date:
**Re: Linguistics Graphs**
Prev by thread:
**Re: ColorFunction and/or ColorOutput - mkdk**
Next by thread:
**Re: Plotting Data**
| |