3
$\begingroup$

This question already has an answer here:

In reference to the following code:

Button["Start", Print[Plot[x^3, {x, -1, 1}]]]

When I click on the button the first time, I get a plot of $y = x^3$, perfect. When I click "Start" a second time, however, I find the new plot does not over-write the first, but appears below it, and I do not like that. How can I make the second plot overwrite the previous?

$\endgroup$

marked as duplicate by m_goldberg, LLlAMnYP, MarcoB, Öskå, dr.blochwave Aug 20 '15 at 23:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7
$\begingroup$

One way, based on the self-delete example in the documentation for Button:

Button["Start", SelectionMove[ButtonNotebook[], All, GeneratedCell]; 
 NotebookDelete[ButtonNotebook[]]; Print[Plot[x^3, {x, -1, 1}]]]
$\endgroup$
  • $\begingroup$ Great!!!! Thanks!! $\endgroup$ – TeM Aug 20 '15 at 12:44

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