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?


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}]]]
  • $\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.