Re: animated, variable color lines in ListPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg15669] Re: animated, variable color lines in ListPlot
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 30 Jan 1999 04:29:01 -0500 (EST)
- References: <78pc1u$d17@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Dick Phillips wrote in message <78pc1u$d17 at smc.vnet.net>...
>Hi,
>
>I'm trying to do an animation of the progressive development of a curve
>in ListPlot, where the color of a just-revealed segment of the curve is
>different from the previously-displayed segment. That is, at the end of
>the animation, the complete curve will be multi-colored. It's easy to
>change the color of the ENTIRE cuve at each time step, but I need to
>show the color evolution.
>
>Thanks for any ideas on how to do this.
>
>Dick Phillips
>
Dick,
I'd be inclined to start from the data:
data= Table[Random[],{10},{2}];
List the ends ot the segments.
endsList =Partition[data, 2,1];
Add the position of each end.
indexedEndsList = MapIndexed[List[#1, #2[[1]]]&,endsList];
Define the style of a segment in terms of the ends and its position
(index).
style[ends_,index_]:= Hue[.7 index/(Length[indexedEndsList])];
(*example only - choose your own styling*)
Make list of styled segments.
f[{ends_,index_}]:= {style[ends, index], Line[ends]};
styledLine=Map[f,indexedEndsList];
Show the development of the plot
Do[
Show[Graphics[Take[styledLine,n]],
PlotRange->
{{Min[First/@data],Max[First/@data]},
{Min[Last/@data],Max[Last/@data]}},
Axes->True,
AxesOrigin -> {0,0}
],
{n,Length[data]-1}
]
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565