MathGroup Archive 2009

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

Search the Archive

Re: User defined color function for discrete data set?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105803] Re: [mg105777] User defined color function for discrete data set?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 20 Dec 2009 06:52:02 -0500 (EST)
  • Reply-to: hanlonr at cox.net

I think the problem was on my end.

f[x_] := Exp[-x^2] Exp[2 I x]

xlist = Range[-3, 3, .1];

data = {#, f[#]} & /@ xlist;

Using only data

cf = Interpolation[
   {#[[1]], Arg[#[[2]]]} & /@ data];

ListLinePlot[{#[[1]], Abs[#[[2]]]} & /@ data,
 Filling -> Axis,
 ColorFunction -> (Hue[cf[#1]] &)]


Bob Hanlon

---- Porscha Louise McRobbie <pmcrobbi at umich.edu> wrote: 

=============
Thanks, but I don't think I phrased my question clearly enough.

What I have is two lists of numbers (that I'm generating from a  
Fortran code), so I'm not able to actually define f in a closed form.  
Is there a way to do a colorfunction in this case?

Thanks!
Porscha

Quoting Bob Hanlon <hanlonr at cox.net>:

>
> You define the ColorFunction the same in both cases.
>
> f[x_] := Exp[-x^2] Exp[2 I x]
>
> xlist = Range[-3, 3, .1];
>
> GraphicsColumn[{
>   Plot[Abs[f[x]], {x, -3, 3},
>    Filling -> Axis,
>    ColorFunction ->
>     (Hue[Arg[f[#1]]] &)],
>   ListLinePlot[
>    {#, Abs[f[#]]} & /@ xlist,
>    Filling -> Axis,
>    ColorFunction ->
>     (Hue[Arg[f[#1]]] &)]}]
>
>
> Bob Hanlon
>
> ---- Porscha Louise McRobbie <pmcrobbi at umich.edu> wrote:
>
> =============
> Hello,
>
> If I define a complex function, I can easily plot its modulus and
> color it according to its argument as:
>
> f[x_] := Exp[-x^2] Exp[2 I x]
> Plot[Abs[f[x]], {x, -3, 3}, Filling -> Axis,
>   ColorFunction -> (Hue[  Arg[f[#1]]] &)]
>
> I'd like to do the same thing, but now with a discrete set of points.
> If I have the following plot:
>
> xlist = Table[j, {j, -3, 3, .1}];
> flist = Table[f[j], {j, -3, 3, .1}];
> data = Thread[{xlist, flist}];
> ListLinePlot[Thread[{xlist, Abs[flist]}], Filling -> Axis]
>
> Using a built-in color scheme is easy, I just add the option
> ColorFunction->scheme.  But how can I define my own color function? Is
> it possible to use ColorData somehow?
>
> My apologies if this is in the Documentation, I cannot seem to find a
> relevant example.
>
> Thanks!
> Porscha
>



  • Prev by Date: Re: What's up with the order of Eigenvalues
  • Next by Date: Re: CellChangeTimes?
  • Previous by thread: Re: User defined color function for discrete data set?
  • Next by thread: Re: Is it possible to dynamically construct arguments to With[]?