1
$\begingroup$

I not sure if the question has been asked or not. I tried to find something similar without success.

I have this small code:

Manipulate[Plot[Sin[a x], {x, 0, 2}], {a, 1, 10}]

The output is ok. when I changed a using the Manipulate controller bar, the output is ok too. But when I used the keyboard to enter value of a and then Enter, I get a duplicate output:

enter image description here

Did I do something wrong to get this output?

Thank you

$\endgroup$
6
  • 1
    $\begingroup$ I can reproduce that only for Shift+Enter event or numeric keyboard Enter. It always has been a little bit annoying. $\endgroup$
    – Kuba
    Jan 7, 2015 at 19:25
  • 2
    $\begingroup$ Very annoying.. $\endgroup$ Jan 7, 2015 at 19:28
  • 2
    $\begingroup$ Shift+Enter means evaluate the current cell (if it is evaluatable). When you evaluate a Manipulate output, it evaluates to another (instance of a) Manipulate, as well as converting the output cell to an input cell as shown by the In/Out tags in your screen shot. However annoying it is, the behavior is quite consistent with the documented behavior sifht+enter, which must be familiar to any somewhat experienced user. $\endgroup$
    – Michael E2
    Jan 7, 2015 at 21:13
  • 1
    $\begingroup$ Using Enter (Return keyboard button without shift) solves the issue. $\endgroup$ Jan 7, 2015 at 22:05
  • $\begingroup$ I use Tab myself, but it changes focus and selects the InputField text. $\endgroup$
    – Michael E2
    Jan 7, 2015 at 22:10

2 Answers 2

2
$\begingroup$

Your code defines the Control to be a Slider by default. Typing into a different device, the InputField, yields a separate computation and separate output cell.

If you'd like to change the Control for input to be an InputField so you can type different values of a without producing different output cells, try this:

Manipulate[Plot[Sin[a x], {x, 0, 2}], {{a, 5}, InputField}]
$\endgroup$
0
$\begingroup$

A workaround I use is to put a semicolon at the end of the graph in the Manipulate Cell, this prevents printing more copies of the graph each time data is entered in the InputField.

$\endgroup$

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.