I am attempting to create a threshold which can be manually adjusted when necessary, but otherwise is assumed to be constant. This corresponds to a list of values, wherein all later values are set equal to the current one, which is manually adjustable.

I have a working draft of this:

d=ConstantArray[0.5,6];(*Initial Values*)
Grid[{{VerticalSlider[Dynamic[d[[i]]]],(*Manually Change Values*) 


However, it has issues with being VERY slow (the real data will have many more points than 6), and seems to require that I display the values themselves when setting them (this is possibly easy to fix, but I haven't found it yet). Does anyone know of a faster/better method?

  • $\begingroup$ You can get rid of the inner table and just do d[[i ;; l]] = d[[i]]. If you want to be able to move the slider without loads of updates, try setting the UpdateInterval on the dynamics to a higher number. Use a semicolon to disable the output display of the values - you also don't need the final dynamic if I understand your problem correctly. $\endgroup$
    – flinty
    Aug 10, 2020 at 15:04

2 Answers 2


Below the behavior differs slightly from the OP in that the array d is not updated when a new slide is chosen. The OP's method was causing continuous updating, which slowed the app's responsiveness. Here the update is within the Dynamic[] update function, which triggers just one update per slider move. One can shave a little time off using Graphics[] instead of ListLinePlot[]. However, ListLinePlot[] is more convenient and probably fast enough. Only testing on the actual use-case can confirm.

d = ConstantArray[0.5, 6];(*Initial Values*)
 l = Length[d];
  Table[With[{i = i},
        Dynamic[d[[i]], (d[[i ;; l]] = #) &]
        ](*Manually Change Values*)
         PlotRange -> {All, {0, 1}}]](*Output*)
      {Dynamic[d[[i ;;]]]
       , SpanFromLeft}}]
    ], {i, l}]
  • $\begingroup$ Cool! This is exactly what I was looking for. $\endgroup$
    – ChaSta
    Aug 11, 2020 at 6:39

Is this what you are trying to achieve?

d = ConstantArray[0.5, 99];
modifyd[i_?IntegerQ, value_?NumericQ] := (d[[i]] = value; Join[d[[;; i]], d[[i]] &/@Range[Length@d - i]])
Manipulate[ListLinePlot[modifyd[i, value], PlotRange -> {All, {0, 1}}], {{i,Length@d}, 1, Length@d,1}, {{value, 0.5}, 0, 1}]

enter image description here

  • $\begingroup$ Very cool idea to use manipulate instead of dynamic! $\endgroup$
    – ChaSta
    Aug 11, 2020 at 6:44
  • $\begingroup$ @ChaSta fwiw I hardly if ever use Dynamic in these cases apart from reading out values. Manipulate is my go to, & Mr Puh shows a great example of how one can do this! $\endgroup$ Aug 13, 2020 at 1:20

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.