Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to modify the colour of dots in a ListPlot[Table[function]], e.g

Manipulate[
  ListPlot[Table[{co, se}, {n, nmax}], 
    PlotMarkers -> {Automatic, Tiny},                   
    AspectRatio -> Automatic], 
  Style["Compacting the circle", 16, Bold],
  {{nmax, 5, "Nmax (step 5)"}, 5, 250, 5, Appearance -> "Labeled"},
  Dynamic[
    ParametricPlot[{co, se}, {n, 1, nmax},
      ImageSize -> 300,
      AspectRatio -> 1]],
  ControlPlacement -> Left]

The Manipulate runs over the variable nmax, and the ListPlot runs over n. This means that when nmax varies, the number of dots also varies. What I want is to change the color of those dots when nmax varies.

share|improve this question
    
Your question isn't clear enough, but perhaps you could enhance it by adding some code (a minimal working example) and explaining what you want with more detail. (There are two confusing expressions in your question "each iteration of Manipulate" and "the variable running inside Manipulate") –  belisarius Aug 12 '13 at 0:23
2  
Thanks a lot for your comments and suggestions. I'll try to clarify my question including some code and rewording. –  juancasy Aug 12 '13 at 0:34
    
It sound like PlotStyle is what you're after. –  Michael E2 Aug 12 '13 at 2:57

4 Answers 4

up vote 2 down vote accepted

You didn't define co or se so I'll just substitute something random. Use PlotStyle to control the color.

Manipulate[
 ListPlot[Table[{Cos[n], Sin[n]}, {n, nmax}], 
  PlotMarkers -> {Automatic, Tiny}, AspectRatio -> Automatic, 
  PlotStyle -> If[nmax == 250, Red, Blue]],
 Style["Compacting the circle", 16, Bold],
 {{nmax, 5, "Nmax (step 5)"}, 5, 250, 5, Appearance -> "Labeled"},
 Dynamic[ParametricPlot[{Cos[n], Sin[n]}, {n, 1, nmax}, 
   ImageSize -> 300, AspectRatio -> 1]], ControlPlacement -> Left]

Mathematica graphics

Mathematica graphics

share|improve this answer

Here's a basic example of what you probably mean, which lets you change the color of the plot with a simple control:

Manipulate[
  Plot[
    Sin[x],
      {x, 0, 2 \[Pi]},
    PlotStyle -> color
  ],
  {color, ColorSlider}
]
share|improve this answer

Perhaps what you want is:

Manipulate[
 ListPlot[{Table[{Cos[2 Pi n/250], Sin[2 Pi n/250]}, {n, 250}], 
           Table[{Cos[2 Pi n/250], Sin[2 Pi n/250]}, {n, nmax}]},
           PlotStyle -> {Blue, Directive[PointSize[.02], Red]},
           AspectRatio -> 1, PlotRange -> 1.1 {{-1, 1}, {-1, 1}}],
           Style["Compacting the circle", 16, Bold],
 {{nmax, 5, "Nmax (step 5)"}, 5, 250, 5, Appearance -> "Labeled"}]

Mathematica graphics

Or this?

Manipulate[
 ListPlot[Table[{Cos[2 Pi n/250], Sin[2 Pi n/250]}, {n, nmax}], 
  PlotMarkers -> {Automatic, Tiny}, PlotStyle -> RGBColor[Sequence@RandomReal[{0, 1}, 3]], 
  AspectRatio -> 1, PlotRange -> {{-1, 1}, {-1, 1}}], 
 Style["Compacting the circle", 16, Bold], 
{{nmax, 5, "Nmax (step 5)"}, 5, 250, 5, Appearance -> "Labeled"}, 
 Dynamic[ParametricPlot[{Cos[2 Pi n/250], Sin[2 Pi n/250]}, {n, 1,  nmax}, ImageSize -> 300, 
                        AspectRatio -> 1, PlotRange -> {{-1, 1}, {-1, 1}}]], 
  ControlPlacement -> Left]

Mathematica graphics Mathematica graphics

share|improve this answer

Since you seem to want colored dots rather than a curve, I offer this variation. Note that ListPlot is not used. All the work of plotting the points along the circle is done by Graphics primitives. Sometimes this approach is easier than trying to force a built-in plotting function to jump through hoops it wasn't designed for.

Manipulate[
  Graphics[
    Table[{Hue[ArcTan[co[n], se[n]]/N[2 Pi]], Point@{co[n], se[n]}}, {n, nmax}],
    PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}},
    Axes -> True],
  Style["Compacting the circle", 16, Bold], 
  {{nmax, 5, "Nmax (step 5)"}, 5, 250, 5, Appearance -> "Labeled"}, 
  Dynamic@ParametricPlot[{co[n], se[n]}, {n, 0, nmax},
    ImageSize -> 300,
    PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}],
  ControlPlacement -> Left,
  Initialization :> (co[n_] := Cos[Pi n/125.]; se[n_] := Sin[Pi n/125.])]

manip.png

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.