My goal is to plot the number of locatable points and their average point as fig2. The number of points is set by the slider and they are locatable. My code with nesting Manipulate is as shown below, but an error-'Argument Null in Null is not a valid LinkObject'-occurred. Where should I fix my code as below?

Manipulate[With[{n = n},
  Manipulate[NumberLinePlot[{pts, {Mean[pts]}}, PlotRange -> {0, 4}],
   {pts, RandomReal[{0, 4}, n], Locator, Appearance -> None, 
    LocatorAutoCreate -> True}]], {{n, 2}, 1, 100, 1, 
  Appearance -> "Labeled"}]

fig.1) enter image description here enter image description here

fig.2) enter image description here

  • $\begingroup$ do not use nested Manipulates. I do not think this is even allowed in Wolfram demonstration web site. I remember this was one of the rules long time ago. It is hard enough to get one Manipulate to work right, never mind one inside another :) I never ever had to nest manipulates for any reason. $\endgroup$
    – Nasser
    Sep 27, 2023 at 17:16

1 Answer 1


Maybe something like this?

  NumberLinePlot[{u[[All, 1]], {Mean[u[[All, 1]]]}}, PlotRange -> {0, 4}],
  {{u, {{0, 0}}}, Locator, Appearance -> None, LocatorAutoCreate -> {1, pointCount}},
  {pointCount, 1, 10, 1}]
  • $\begingroup$ MMA 13.3 Unfortunately this does not work. Only 1 point is displayed. $\endgroup$ Sep 28, 2023 at 7:59
  • $\begingroup$ @DanielHuber It works as expected for me on 13.3. You need to use the slider to increase the number of points and you need to command-click to add new points (or remove points). This seems to match what the OP was trying to do. $\endgroup$
    – lericr
    Sep 28, 2023 at 14:09
  • $\begingroup$ There is only 1 point, I can move the slider and command click to no avail. $\endgroup$ Sep 29, 2023 at 7:19
  • $\begingroup$ Does a regular click at least move the single point? $\endgroup$
    – lericr
    Sep 29, 2023 at 13:52
  • $\begingroup$ Yes it does. move the point $\endgroup$ Sep 29, 2023 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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