Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interactive plotting in Python?

Matlab and Mathematica both have features that allow the user to manipulate the contents of a plot using, say, a slider. For example, if you have a set of 3D data, it is easy to make a small program that lets you view 2D slices of a set of 3D data where the user can slide a slider to move through which slice is displayed. Is there anything in python that allows for this sort of capability without tons of effort? For example, is it possible to do such a thing in matplotlib, or something similar? I

Thanks.

like image 272
Chironex Avatar asked May 25 '11 18:05

Chironex


3 Answers

My first thought would be Mayavi, which is great for data visualization, especially in 3D. It relies on VTK. It is included in the Enthought flavoured version of Python, together with Chaco for 2D plotting. To get an idea, look at Travis Vaught's nice screencast in Multidimensional Data Visualization in Python - Mixing Chaco and Mayavi.

It also possible to embed basic interactive functionalities (like slider) to Matplotlib, see matplotlib.widgets and the widget examples.

Finally, you can use rpy (or better, rpy2) and benefit from the R interface.

like image 155
chl Avatar answered Oct 26 '22 00:10

chl


Have you looked at Vtk? http://www.vtk.org/ One of their demos does exactly what you're asking.

like image 35
David Poole Avatar answered Oct 26 '22 00:10

David Poole


In principle, you can do it by help of MathGL. This is cross-platform GPL library for plotting.

For each mouse clicks you can find the x,y,z position in plot or clicked object and adjust (replot) some other information correspondingly. However you should handle mouse clicks by yourself (for example, using PyQt).

like image 25
abalakin Avatar answered Oct 25 '22 23:10

abalakin