Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: ListLinePlot Color each line differently

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131453] Re: ListLinePlot Color each line differently
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 26 Jul 2013 05:45:54 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20130725020507.AE8D26A43@smc.vnet.net>

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