MathGroup Archive 1995

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

Search the Archive

Re: Sequential Plotting, and "INKEY$", in Mathematica?

In article <3mi356$afn at>,
   siegman at (A. E. Siegman) wrote:
->1)    Is there any way in Mathematica to put up a plot, and then add 
->      additional points to it, without generating a new plot?  
->      (E.g., to show a curve on a plot evolving dynamically with time).
You can't add points to an existing plot, but you can do a couple of "next 
best things":

(a)  You can generate incremental plots and then use the animation feature 
to "play them back".

(b)  You can generate an initial plot, then additional plots with just the 
latest added points, and superimpose all those plots (using Show).

The second answer may be closer than the first to what you want.  The first 
answer displays multiple graphs.  The second answer displays a single graph 
each time it's invoked, but it does not involve replotting the previously 
plotted points.  You can make the updated plot replace previous plots by 
doing the following.  Create a plot list p (initially containing your first 
plot).  Write a function that accepts from the user some direction as to 
what points to add, generates a new plot containing only those points, 
appends it to the plot list and then Shows the list.  Set 
DisplayFunction->Identity when generating the incremental plot (so that it 
is not graphed) and DisplayFunction->$DisplayFunction in the Show command 
(so that the plots are displayed, superimposed, at that time).  Each time 
you execute the function, you get an updated plot in place of the previous 
->      I don't think there is, and I think it's one of the biggest
->      weaknesses for educational use of mma.
->2)    Is there any way to start mma on, for example, an iterative or
->      lengthy calculation, and have the program test from time to time
->      whether any input key has been hit _while mma was running_?
->      (In other words, the equivalent of the INKEY$ function in Basic.)
->      Again, I think this is a major weakness of mma.  You might want to
->      start an iterative calculation in mma, watch how the initial 
->      evolve, then hit a key to make the program branch or change values,
->      without stopping it (and without having it stop and wait for you
->      to come back and enter some input).

There's usually a way to interrupt a computation (in the Windoze front-end, 
it's click on the palm-print icon and pray the kernel's paying attention). 
 One way to do what you want is to use a variable as a semaphore.  
Initially set it to some default value, and have the program test it 
intermittently (in lieu of checking INKEY$).  When you want to modify the 
program's behavior, do an interrupt and select the inspection option, which 
starts a separate dialog.  In the dialog, change the value of the semaphore 
and do a Return[] (which returns you to your regularly scheduled program). 
 The next time the program checks the semaphore, it sees a new value and 
reacts accordingly.


* Paul A. Rubin                                  Phone: (517) 432-3509   *
* Department of Management                       Fax:   (517) 432-1111   *
* Eli Broad Graduate School of Management        Net:   RUBIN at MSU.EDU    *
* Michigan State University                                              *
* East Lansing, MI  48824-1122  (USA)                                    *
Mathematicians are like Frenchmen:  whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different.                                    J. W. v. GOETHE

  • Prev by Date: Re: Calling functions before loading the package
  • Next by Date: Re: How do you input a solution from FindRoot into another equation?
  • Previous by thread: Re: Sequential Plotting, and "INKEY$", in Mathematica?
  • Next by thread: PolarPlot ???