From: Malte M. <Mal...@cs...> - 2004-07-20 05:39:57
|
Hi, I am trying to use a script interacively. It basically needs to do the following. * do some work * plot() * Ask whether to keep the data plotted or not etc. This should be done (initially) at the command line using raw_read(). I don't want to close the plot window to get back to the prompt. In terms of a GUI this would be easy as the dialog would run in the same thread as the plot window. But interactive.py doesn't seem to be the solution. BTW, I am running 0.54.2 as I can't get 0.60.2 to compile under debian stable. |
From: John H. <jdh...@ac...> - 2004-07-20 14:49:18
|
>>>>> "Malte" =3D=3D Malte Marquarding <Mal...@cs...> write= s: Malte> Hi, I am trying to use a script interacively. It basically Malte> needs to do the following. Malte> * do some work * plot() * Ask whether to keep the data Malte> plotted or not etc. Malte> This should be done (initially) at the command line using Malte> raw_read(). I don't want to close the plot window to get Malte> back to the prompt. In terms of a GUI this would be easy Malte> as the dialog would run in the same thread as the plot Malte> window. But interactive.py doesn't seem to be the Malte> solution. The best solution for interactive plots is to use the tkagg backend with interactive set to True in your rc file. Use a standard python shell or better yet, ipython. Ie, your rc file should have the settings backend : TkAgg # the default backend interactive : True =20 You can then plot interactively from the shell, and get your prompt back after each command. Fernando Perez has made some preliminary extensions for ipython to support interactive use of matplotlib for TkAgg and may be making an extension for GTKAgg. Very nice for interactive use. Available from http://ipython.scipy.org/ For the 'pylab' extensiosn, save the two files included at the end of this email to your ~/.ipython dir and start ipython with > ipython -p pylab Malte> BTW, I am running 0.54.2 as I can't get 0.60.2 to compile Malte> under debian stable. Please build with=20 > python setup.py build > build.out=20 and post the results to the matplotlib-devel list. Cheers, JDH ### begin pylab # -*- Mode: Shell-Script -*- Not really, but it shows comments correctly #************************************************************************= *** # Configuration file for ipython -- ipythonrc format # # The format of this file is one of 'key value' lines. # Lines containing only whitespace at the beginning and then a # are igno= red # as comments. But comments can NOT be put on lines with data. #************************************************************************= *** # If this file is found in the user's ~/.ipython directory as ipythonrc-p= ylab, # it can be loaded by calling passing the '-profile pylab' (or '-p pylab'= ) # option to IPython. # This profile load modules which turn IPython into a very capable enviro= nment # for numerical work, as compatible with Matlab as possible. # Load the user's basic configuration include ipythonrc # Load all additional matlab-like functionality from Numeric and matplotl= ib execfile matplotlib_load.py ### end pylab ### begin matplotlib_load.py # -*- coding: iso-8859-1 -*- """matlab-like functionality based on matplotlib and Numeric's MLab. Load these modules and configure them for interactive use""" #************************************************************************= ***** # Copyright (C) 2004 Fernando P=C3=A9rez. <fp...@co...> # # Distributed under the terms of the GNU Lesser General Public License (= LGPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # The full text of the LGPL is available at: # # http://www.gnu.org/copyleft/lesser.html #************************************************************************= ***** __author__ =3D 'Fernando P=C3=A9rez. <fp...@co...>' __license__=3D 'LGPL' # Set matplotlib in interactive mode with the TkAgg backend # THESE MUST BE THE FIRST MATPLOTLIB COMMANDS CALLED! import matplotlib matplotlib.use('TkAgg') matplotlib.interactive(True) # Now we can continue... # Load these by themselves so that 'help MODULE' works import matplotlib.matlab as matlab # MA (MaskedArray) modifies the Numeric printing mechanism so that huge a= rrays # are only summarized and not printed (which could freeze the machine for= a # _long_ time). import MA # Bring all of the numeric and plotting commands to the toplevel namespac= e from IPython.numutils import * from matplotlib.matlab import * print """Welcome to pylab, a matlab-like python environment. help(Numeric) -> help on NumPy, Python's basic numerical library. help(matlab) -> help on matlab compatible commands from matplotlib. help(plotting) -> help on plotting commands. """ ### end matplotlib_load.py |