MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Erasing a Plot?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20727] RE: [mg20665] Erasing a Plot?
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Wed, 10 Nov 1999 00:17:43 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

siegman at stanford.edu  wrote:
-------------------------------

I'd like to have a program draw a plot; compute for a while; erase the old
plot and draw a new one in the same screen space; and loop indefinitely in
this fashion (kind of a slowed-down version of animating graphics)  

-------------------------------
ANSWER

If all you want to do is delete a cell you can use something like: 
nb=SelectedNotebook[];
....
....
SelectionMove[nb,Previous,Cell]; 
NotebookDelete[nb].


Below I adapt some code Dale Horton once suggested to make Plot display
graphics in a separate notebook.  I think you can let this run and run
without running out of memory. It makes a plot of Sin[x]-Sin[Pi x] where the
x axis slowly scrolls to the right.  Use the menu selection (Kernel ->
Abort) evaluation to make it stop.


s=0;
nb=NotebookCreate[];
While[True,
  (Plot[Sin[x]-Sin[Pi x],{x,s,s+8},
     Axes->{True,False},
     PlotRange->{All,{-2,2}},
     DisplayFunction-> (
       NotebookWrite[nb,
         Cell[GraphicsData["PostScript",DisplayString[#]],"Graphics"]]&)];
    SelectionMove[nb,Previous,Cell];
    Pause[0.001];
    s=s+0.1)]


--------------------
Regards,
Ted Ersek

For Mathematica tips, tricks see 
http://www.dot.net.au/~elisha/ersek/Tricks.html


  • Prev by Date: once more integrate
  • Next by Date: Cool new stuff at MathSource
  • Previous by thread: Erasing a Plot?
  • Next by thread: Re: Erasing a Plot?