# What is the proper way to use Manipulate and Graphics in this context?

So this is my setup: I want to have an unspecified number of points, let's say n, which I can manipulate in a Manipulate environment. I want to later use these points to plot an InterpolatingPolynomial through them, but that is out of the scope for now. The main problem that I'm facing is that the points are not evaluated like I want to and they stay in their symbolic form. I tried the following code:

n = 3;
pts := Table[Evaluate[Subscript[p, i]], {i, 1, n}];
locators =
Sequence @@
Table[{{Subscript[p, i], AngleVector[(2 \[Pi])/3 i]}, Locator}, {i,
1, n}];
Manipulate[
curPoints = Evaluate[Evaluate /@ pts];
Evaluate@
Graphics[Evaluate[Point /@ curPoints], PlotRange -> 1,
Axes -> True], Evaluate@locators]


This gives output as shown below. When you hover over it, it gives the error "Coordinate Subscript[$CellContextp,1] should be a pair of numbers, or a Scaled or Offset form.", which indicates the various p_1, p_2, p_3 are not evaluated but remain in their symbolic form. The various Evaluate's in my code snippet above are me trying to make them evaluate but to no avail. To make it more clear what I want: I want to have code equivalent to Manipulate[ curPoints = {p1, p2, p3}; Graphics[Point /@ curPoints, PlotRange -> 1, Axes -> True], {p1, Locator}, {p2, Locator}, {p3, Locator}]  but I want the number of points to be unspecified (not hardcoded). ## 1 Answer $Version

(* "13.2.0 for Mac OS X x86 (64-bit) (November 18, 2022)" *)

Clear["Global*"]

n = 3;
pts = Array[p, n];

locators =
Sequence @@
Table[{{p[i], AngleVector[(2 π)/3 i]}, Locator}, {i, 1, n}];

Manipulate @@ {curPoints = pts;
Column[{
Graphics[
Point[curPoints],
PlotRange -> 1,
Axes -> True,
ImageSize -> Medium],
Column[
StringForm[" = ", Subscript[p, #], p[#]] & /@
Range[3]]}],
locators}


• Amazing! What is the trick that made this work? The fact that Manipulate is Applied to a list instead of directly applying it to its arguments? How does that make it do the right thing? Dec 21, 2022 at 10:15
• Manipulate has the attribute HoldAll. By first putting everything in a list it ensures that everything gets evaluated before it is handed to Manipulate` Dec 21, 2022 at 15:20