       Re: {mg4240] Plot and colors

• To: mathgroup at smc.vnet.net
• Subject: [mg4334] Re: {mg4240] Plot and colors
• From: jpk at apex.mpe.FTA-Berlin.de (Jens-Peer Kuska)
• Date: Thu, 11 Jul 1996 00:58:04 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Laurent

here is the principle solution.

Needs["Utilities`FilterOptions`"]

Options[ColorPlot]:=
{ColorFunction ->Hue,Axes->True}

ColorPlot[f_,{x_,x0_,xe_},opt___]:=
Module[{gr,cfun},
cfun=ColorFunction /. {opt} /. Options[ColorPlot];
gr=First[
Plot[
f,{x,x0,xe},
DisplayFunction->
Identity
]
] //. Line[{a_,b_,c__}] :>
Sequence @@ {Line[{a,b}],
Line[{b,c}]} /.
Line[{a_,b_}] :>
{cfun[Last[a+b]],Line[{a,b}]};
Show[
Graphics[
gr,
Sequence @@
{FilterOptions[Graphics,opt],
FilterOptions[Graphics,Sequence @@ Options[Plot]]}
]
]
]

Now

ColorPlot[Sin[x],{x,0,Pi}]

works. You may set the desired color function with the option ColorFunction.
A rescaling to the maximum/min range may be usefull, but this is a quick
and dirty solution. Here the explanation. Plot generates one line with
all points of the curve, to color the different line segments one must split
the one long line into a list of lines connecting only two points, the
replacement Line[{a_,b_,c__}] :> .. does this. Than one has to add the color
information for every line segment by replacing every line segment by a color
directive due to the ave y-value and the original line information. In the last
step a graphics object is created with the options of Plot ( axes ..).

Hope that helps

Jens

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: Abort options in Windows
• Next by Date: [Q] CountorPlot as part of 3D Plot
• Previous by thread: Re: Abort options in Windows
• Next by thread: [Q] CountorPlot as part of 3D Plot