4
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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") $\endgroup$ – Dr. belisarius Aug 12 '13 at 0:23
  • 2
    $\begingroup$ Thanks a lot for your comments and suggestions. I'll try to clarify my question including some code and rewording. $\endgroup$ – juancasy Aug 12 '13 at 0:34
  • $\begingroup$ It sound like PlotStyle is what you're after. $\endgroup$ – Michael E2 Aug 12 '13 at 2:57
2
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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}
]
$\endgroup$
3
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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