MathGroup Archive 2013

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

Search the Archive

Re: ListLinePlot Color each line differently


data2 = Table[Accumulate[RandomReal[{-1, 1}, 250]], {3}];


blend1 = (Blend[{{0, Green}, {1, Red}}, #] &);


You are varying the color of all three lines by their x coordinates


p2 = ListLinePlot[data2,
  ColorFunction -> (blend1[#1] &),
  ImageSize -> 500,
  Background -> None,
  PlotStyle -> Thickness[0.0025]]


To color all three lines by their y coordinates use


p2 = ListLinePlot[data2,
  ColorFunction -> (blend1[#2] &),
  ImageSize -> 500,
  Background -> None,
  PlotStyle -> Thickness[0.0025]]


To apply a separate color to each line, use PlotStyle


p2 = With[{nmax = Length[data2] - 1},
  ListLinePlot[data2,
   ImageSize -> 500,
   Background -> None,
   PlotStyle -> Table[
     {blend1[n/nmax], Thickness[0.0025]},
     {n, 0, nmax}]]]



Bob Hanlon




On Wed, Jul 24, 2013 at 10:05 PM, <kuzumadam at gmail.com> wrote:

> Hi, I have a line plot made from an imported .xlsx file. I have made my
> own color blend and want to color each line differently according to this
> blend - how do I do this? Currently my blend will only work across the x or
> z axis.
>
> data2 = Import["SAXS_SIM_EDR10_23JUL.xlsx"]
>
> blend1 = (Blend[{{0, Green}, {1, Red}}, #] &);
> Graphics[Table[{blend1[x], Disk[{8 (x + 1), 0}]}, {x, 0, 1, 1/8}]]
>
> p2 = ListLinePlot[data2, PlotRange -> {{0, 0.7}, {-1, -5}},
>   ColorFunction -> (blend1[#1] &), ImageSize -> 500,
>   Background -> None, PlotStyle -> Thickness[0.0025]]
>
> Thanks in advance,
> Toni
>
>




  • Prev by Date: Re: Mathematica v9.0 on linux -- Plot3D
  • Next by Date: CUDAFunctionLoad error with windows 7 64 bits
  • Previous by thread: ListLinePlot Color each line differently
  • Next by thread: CUDAFunctionLoad error with windows 7 64 bits