There are so many 3d plotting packages, but I'm looking for something simple that'll resemble 3d plots of Gnuplot/Mathematica, can someone recommend one? -- Yaroslav Bulatov bulatov@cs.oregonstate.edu Dearborn 102 Oregon State University Corvallis, OR
You can actually use Gnuplot from Python. I have had the best luck with the Gnuplot.py package (http://gnuplot-py.sourceforge.net/). If it doesn't implement the features you want, you can send pure gnuplot code from your python script to the gnuplot session. Mayavi is pretty good but I think a bit more complicated (http://mayavi.sourceforge.net/). It can do some neat animations. But, it doesn't do as nice a job of generating post-script files as gnuplot. I use mayavi for animations and gnuplot.py for print quality graphics. Ryan Yaroslav Bulatov wrote:
There are so many 3d plotting packages, but I'm looking for something simple that'll resemble 3d plots of Gnuplot/Mathematica, can someone recommend one?
-- Yaroslav Bulatov bulatov@cs.oregonstate.edu Dearborn 102 Oregon State University Corvallis, OR
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
I might have posted this little bit of code before, but it's not too much so I hope no one minds seeing it again. It's not mine, so for proper cretids, Google a unique-looking line and it should pop right up. With this, you can get to gnuplot with a minimum of fuss. Note that it sets up AquaTerm (that's a "plotting terminal" for OS X that uses native antialiased graphics with PDF saving, etc. If you don't use it, delete the line or set to your own terminal. import os class gnuplot: def __init__(self): print "opening new gnuplot session..." self.session = os.popen("gnuplot","w") def __del__(self): print "closing gnuplot session..." self.session.close() def send(self, cmd): self.session.write(cmd+'\n') self.session.flush() if __name__=="__main__": g1 = gnuplot() g1.send("set terminal aqua 0") # Your code here g1.send("plot sin(x)") del g1 On Sep 28, 2005, at 2:57 PM, Ryan Krauss wrote:
You can actually use Gnuplot from Python. I have had the best luck with the Gnuplot.py package (http://gnuplot-py.sourceforge.net/). If it doesn't implement the features you want, you can send pure gnuplot code from your python script to the gnuplot session.
Mayavi is pretty good but I think a bit more complicated (http:// mayavi.sourceforge.net/). It can do some neat animations. But, it doesn't do as nice a job of generating post-script files as gnuplot. I use mayavi for animations and gnuplot.py for print quality graphics.
Ryan
Yaroslav Bulatov wrote:
There are so many 3d plotting packages, but I'm looking for something simple that'll resemble 3d plots of Gnuplot/Mathematica, can someone recommend one? -- Yaroslav Bulatov bulatov@cs.oregonstate.edu Dearborn 102 Oregon State University Corvallis, OR _______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
"Ryan" == Ryan Krauss <ryanfedora@comcast.net> writes:
Ryan> Mayavi is pretty good but I think a bit more complicated Ryan> (http://mayavi.sourceforge.net/). It can do some neat Ryan> animations. But, it doesn't do as nice a job of generating Ryan> post-script files as gnuplot. Ryan> I use mayavi for animations and gnuplot.py for print Ryan> quality graphics. Thanks. Just a clarification. It is not easy to generate vector graphics output for complex visualizations. However, if you build VTK with GL2PS support it should be possible to generate true vector PS/EPS/PDF output. This works pretty well for simple visualizations. IMHO, MayaVi is complicated primarily because you need to create your data as per some format or another. I am hoping to do something about that in the next several months. If you are willing to try and go over a few hoops installing the enthought tool suite (no installers yet) you can get it from SVN and try out the tools inside the TVTK package. Some preliminary information is available here (I'll update the pages over the next week): http://www.enthought.com/enthought/wiki/TVTK There are links to papers and presentations on TVTK there. With TVTK's mlab module (enthought.tvtk.tools.mlab) you can create simple visualizations with pure Numeric/numarray data. It is like mayavi.tools.imv but a lot better with many more features. I'll announce this as soon as I have written a little more documentation on installation of the enthought tool suite and a better TVTK web page. Hopefully that will happen by next week. If you are interested to check it out right away, it might be a good idea to just read the EuroPython2005 paper and presentation at the above site. cheers, prabhu
Prabhu Ramachandran wrote: [...]
that in the next several months.
If you are willing to try and go over a few hoops installing the enthought tool suite (no installers yet) you can get it from SVN and try out the tools inside the TVTK package. Some preliminary information is available here (I'll update the pages over the next week):
That sounds very interesting. Do I need a complete enthought installation to be able to use tvtk? Anyway I couldn't build enthought so I would need some hints here. I tried python setup_enthought.py build in a fresh svn copy and I get the following error: Traceback (most recent call last): File "setup_enthought.py", line 143, in ? setup_package() File "setup_enthought.py", line 135, in setup_package url="http://www.scipy.org/", File "/usr/lib/python2.3/site-packages/scipy_distutils/core.py", line 73, in setup return old_setup(**new_attr) File "/usr/lib/python2.3/distutils/core.py", line 149, in setup dist.run_commands() File "/usr/lib/python2.3/distutils/dist.py", line 907, in run_commands self.run_command(cmd) File "/usr/lib/python2.3/distutils/dist.py", line 927, in run_command cmd_obj.run() File "/usr/lib/python2.3/distutils/command/build.py", line 107, in run self.run_command(cmd_name) File "/usr/lib/python2.3/distutils/cmd.py", line 333, in run_command self.distribution.run_command(command) File "/usr/lib/python2.3/distutils/dist.py", line 927, in run_command cmd_obj.run() File "/usr/lib/python2.3/site-packages/scipy_distutils/command/build_src.py", line 129, in run self.build_sources() File "/usr/lib/python2.3/site-packages/scipy_distutils/command/build_src.py", line 215, in build_s ources self.build_extension_sources(ext) File "/usr/lib/python2.3/site-packages/scipy_distutils/command/build_src.py", line 249, in build_e xtension_sources sources = self.generate_sources(sources, ext) File "/usr/lib/python2.3/site-packages/scipy_distutils/command/build_src.py", line 291, in generat e_sources source = func(extension, build_dir) File "/usr/lib/python2.3/site-packages/scipy_distutils/misc_util.py", line 565, in generate_svn_ve rsion_py local_path = extension.local_path AttributeError: Extension instance has no attribute 'local_path' Regards, Christian
"Christian" == Christian Kristukat <ckkart@hoc.net> writes:
>> http://www.enthought.com/enthought/wiki/TVTK Christian> That sounds very interesting. Do I need a complete Christian> enthought installation to be able to use tvtk? Anyway I Christian> couldn't build enthought so I would need some hints Christian> here. I tried python setup_enthought.py build in a Christian> fresh svn copy and I get the following error: Thanks for trying this out. In the next couple of days I'll create a wiki page for installation and also post on this list with a link. For now here are some initial instructions (which will eventually get on the wiki). Requirements ------------ 1. SciPy (and therefore numerix) 2. You will need arrayobject.h (i.e. the dev package for numerix). 3. A working VTK-Python installation. 4. For the UI you will need a working wxPython-2.6.x. 5. *Optionally* (if you want to try chaco, enable, kiva etc.) you will need SWIG to build kiva. This is *not* necessary for TVTK. Note that SWIG is packaged with Enthon (see below). Note that none of this is really tested under Mac OS X. I'll defer to Robert Kern for issues on that platform :). TVTK and MayaVi2 and friends all work on Linux and Win32. On Win32: --------- Under win32 you can simply install this version of Enthon (it works for me on XP) to get *all* the requirements: http://download.enthought.com/enthought_python-2.3.5-1076-wx26-n238.exe In fact, if you install this, you may simply get the enthought svn tree (as shown below) and double click on enthought/src/build_inplace.bat and you should be all set except you'll need to set your PYTHONPATH to point to the enthought directory (also shown below). Building and setup ------------------ Once you have the requirements setup. You can do the following: $ svn co http://www.enthought.com/svn/enthought/trunk enthought $ # Build traits. $ cd enthought/src/lib/enthought/traits $ python setup.py build_ext --inplace $ # Build tvtk $ cd ../tvtk $ python setup.py build_ext --inplace # For want of a working installer, lets just set PYTHONPATH for now. $ export PYTHONPATH=$PYTHONPATH:/path/to/enthought/src/lib/ Then try this: $ cd examples $ python tiny_mesh.py $ python simple.py $ python ivtk_example.py If that works, you are ready to play with mlab.py which is inside enthought/tvtk/tools/mlab.py. You can run the file as it is, to see a spherical harmonic on screen. See the source for some nice examples. If you have come this far, I hope you are rewarded by all the new tools you can play with. :) cheers, prabhu
Prabhu Ramachandran wrote:
If that works, you are ready to play with mlab.py which is inside enthought/tvtk/tools/mlab.py. You can run the file as it is, to see a spherical harmonic on screen. See the source for some nice examples.
If you have come this far, I hope you are rewarded by all the new tools you can play with. :)
Wow!!! That was easy. I'm very impressed. Only the ivtk example isn't working. I'm using vtk python 4.2.6. The traceback follows: Exception occurred in traits notification handler Traceback (most recent call last): File "/home/ck/testarea/trunk/src/lib/enthought/traits/trait_notifiers.py", line 214, in rebind_call_1 getattr( self.object(), self.name )( new ) File "/home/ck/testarea/trunk/src/lib/enthought/pyface/tvtk/scene.py", line 699, in _background_changed self.render() File "/home/ck/testarea/trunk/src/lib/enthought/pyface/tvtk/scene.py", line 205, in render self.control.Render() File "/usr/lib/python2.3/site-packages/vtk_python/vtk/wx/wxVTKRenderWindowInteractor.py", line 339, in Render self._Iren.GetRenderWindow().SetNextWindowInfo(str(self.GetHandle())) AttributeError: SetNextWindowInfo Aborted Regards, Christian
"Christian" == Christian Kristukat <ckkart@hoc.net> writes:
Christian> Prabhu Ramachandran wrote: >> If that works, you are ready to play with mlab.py which is >> inside enthought/tvtk/tools/mlab.py. You can run the file as >> it is, to see a spherical harmonic on screen. See the source >> for some nice examples. >> >> If you have come this far, I hope you are rewarded by all the >> new tools you can play with. :) Christian> Wow!!! That was easy. I'm very impressed. Only the ivtk Christian> example isn't working. I'm using vtk python 4.2.6. The Christian> traceback follows: Terrific! VTK-4.4 is worth upgrading to if possible. In any case, I forgot that you can also run all the tests in tvtk/tests to make sure the core functionality works. I do the following: $ cd tvtk/tests $ for i in *.py; do echo $i; python $i; done [...] Christian> "/usr/lib/python2.3/site-packages/vtk_python/vtk/wx/wxVTKRenderWindowInteractor.py", Christian> line 339, in Render Christian> self._Iren.GetRenderWindow().SetNextWindowInfo(str(self.GetHandle())) If you are willing to do a little bit of surgery, just replace that file (wxVTKRenderWindowInteractor.py), with the latest from here: http://public.kitware.com/cgi-bin/viewcvs.cgi/Wrapping/Python/vtk/wx/wxVTKRenderWindowInteractor.py?rev=1.17&view=log Then it should hopefully work provided you have wxPython-2.6.x. Good luck and please let us know how this goes. cheers, prabhu
Prabhu Ramachandran wrote:
"Christian" == Christian Kristukat <ckkart@hoc.net> writes:
Christian> Prabhu Ramachandran wrote: >> If that works, you are ready to play with mlab.py which is >> inside enthought/tvtk/tools/mlab.py. You can run the file as >> it is, to see a spherical harmonic on screen. See the source >> for some nice examples. >> >> If you have come this far, I hope you are rewarded by all the >> new tools you can play with. :)
Christian> Wow!!! That was easy. I'm very impressed. Only the ivtk Christian> example isn't working. I'm using vtk python 4.2.6. The Christian> traceback follows:
Terrific! VTK-4.4 is worth upgrading to if possible. In any case, I forgot that you can also run all the tests in tvtk/tests to make sure the core functionality works. I do the following:
I upgraded to 4.4.2 and now simple.py is no longer working. Is that a TK issue? Traceback (most recent call last): File "simple.py", line 45, in ? bw = tvtk.BoxWidget(interactor=rwi, place_factor=1.25, AttributeError: 'TVTK' object has no attribute 'BoxWidget' And the ivtk example now results in a X error: ** (python:24725): WARNING **: Cannot open font file for font Adobe Helvetica 12 ** (python:24725): WARNING **: Cannot open font file for font Adobe Helvetica 14The program 'python' received an X Window System error. This probably reflects a bug in the program. The error was 'BadWindow (invalid Window parameter)'. (Details: serial 7 error_code 3 request_code 2 minor_code 0) (Note to programmers: normally, X errors are reported asynchronously; that is, you will receive the error a while after causing it. To debug your program, run it with the --sync command line option to change this behavior. You can then get a meaningful backtrace from your debugger if you break on the gdk_x_error() function.)
$ cd tvtk/tests $ for i in *.py; do echo $i; python $i; done
Most of them work. I've got no numarray installed but I doubt that it's necessary. test_array_ext_na.py Traceback (most recent call last): File "test_array_ext_na.py", line 10, in ? import numarray ImportError: No module named numarray test_array_ext.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.096s OK test_array_handler.py ...... ---------------------------------------------------------------------- Ran 6 tests in 0.574s OK test_class_tree.py ...... ---------------------------------------------------------------------- Ran 6 tests in 0.127s OK test_indenter.py ......... ---------------------------------------------------------------------- Ran 9 tests in 0.019s OK test_messenger.py ..... ---------------------------------------------------------------------- Ran 5 tests in 0.005s OK test_tvtk_base.py ........... ---------------------------------------------------------------------- Ran 11 tests in 0.055s OK test_tvtk.py ....F................ ====================================================================== FAIL: Test the caching of ancestor classes. ---------------------------------------------------------------------- Traceback (most recent call last): File "test_tvtk.py", line 80, in test_cache self.assertEqual(tvtk_helper._cache.has_key(i), True) File "/usr/lib/python2.3/unittest.py", line 302, in failUnlessEqual raise self.failureException, \ AssertionError: False != True ---------------------------------------------------------------------- Ran 21 tests in 14.962s FAILED (failures=1) test_vtk_parser.py ..... ---------------------------------------------------------------------- Ran 5 tests in 4.475s OK test_wrapper_gen.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.005s OK
[...] Christian> "/usr/lib/python2.3/site-packages/vtk_python/vtk/wx/wxVTKRenderWindowInteractor.py", Christian> line 339, in Render Christian> self._Iren.GetRenderWindow().SetNextWindowInfo(str(self.GetHandle()))
If you are willing to do a little bit of surgery, just replace that file (wxVTKRenderWindowInteractor.py), with the latest from here:
That did not work neither. He's complaining about different VTK versions.
Then it should hopefully work provided you have wxPython-2.6.x.
Yes, I've wxPyhton 2.6.1. Regards, Christian
"Christian" == Christian Kristukat <ckkart@hoc.net> writes:
>> Terrific! VTK-4.4 is worth upgrading to if possible. In any >> case, I forgot that you can also run all the tests in >> tvtk/tests to make sure the core functionality works. I do the >> following: Christian> I upgraded to 4.4.2 and now simple.py is no longer Christian> working. Is that a TK issue? [...] Did you rebuild TVTK after upgrading to 4.4.2? If you did not, then remove the tvtk_classes.zip file and rebuild TVTK like so: python setup.py build_ext --inplace You should have gotten warning messages if you did not do this and imported TVTK. Also, did you build the Hybrid classes when you built 4.4.2? >> $ cd tvtk/tests $ for i in *.py; do echo $i; python $i; done Christian> Most of them work. I've got no numarray installed but I Christian> doubt that it's necessary. Yes, that is unnecessary. So that can be ignored. The ancestor caching should I think go away when you rebuild TVTK. >> If you are willing to do a little bit of surgery, just replace >> that file (wxVTKRenderWindowInteractor.py), with the latest >> from here: >> >> http://public.kitware.com/cgi-bin/viewcvs.cgi/Wrapping/Python/vtk/wx/wxVTKRenderWindowInteractor.py?rev=1.17&view=log Christian> That did not work neither. He's complaining about Christian> different VTK versions. Sorry, who is complaining about different versions? Thanks for the patient testing. cheers, prabhu
Hi Prabhu, I'll switch to the mayavi mailing list, ok? Prabhu Ramachandran wrote:
"Christian" == Christian Kristukat <ckkart@hoc.net> writes:
>> Terrific! VTK-4.4 is worth upgrading to if possible. In any >> case, I forgot that you can also run all the tests in >> tvtk/tests to make sure the core functionality works. I do the >> following:
Christian> I upgraded to 4.4.2 and now simple.py is no longer Christian> working. Is that a TK issue? [...]
Did you rebuild TVTK after upgrading to 4.4.2? If you did not, then remove the tvtk_classes.zip file and rebuild TVTK like so:
Yes, I've seen the warning message and rebuilt tvtk. After that, I got the error about the missing BoxWidget.
>> If you are willing to do a little bit of surgery, just replace >> that file (wxVTKRenderWindowInteractor.py), with the latest >> from here: >> >> http://public.kitware.com/cgi-bin/viewcvs.cgi/Wrapping/Python/vtk/wx/wxVTKRenderWindowInteractor.py?rev=1.17&view=log
Christian> That did not work neither. He's complaining about Christian> different VTK versions.
Sorry, who is complaining about different versions?
Well, I can't reproduce this now as I already upgraded to vtk 4.4.2 but when starting the ivtk example there was a message saying, if I remember right, that there is a version mismatch between some image lib (libpng?) of the system and that with which VTK was compiled...? Something like that.
Thanks for the patient testing.
No problem, I'm just curious about the results. Regards, Christian
Prabhu, I would be really interested in getting eps/pdf output. How hard would it be to get this working in Windows? I don't even mind if the drawing part of the figure is somewhat pixelated, I just think it looks bad when the axes and labels aren't type set well. Ryan Prabhu Ramachandran wrote:
"Ryan" == Ryan Krauss <ryanfedora@comcast.net> writes:
Ryan> Mayavi is pretty good but I think a bit more complicated Ryan> (http://mayavi.sourceforge.net/). It can do some neat Ryan> animations. But, it doesn't do as nice a job of generating Ryan> post-script files as gnuplot. Ryan> I use mayavi for animations and gnuplot.py for print Ryan> quality graphics.
Thanks. Just a clarification. It is not easy to generate vector graphics output for complex visualizations. However, if you build VTK with GL2PS support it should be possible to generate true vector PS/EPS/PDF output. This works pretty well for simple visualizations.
IMHO, MayaVi is complicated primarily because you need to create your data as per some format or another. I am hoping to do something about that in the next several months.
If you are willing to try and go over a few hoops installing the enthought tool suite (no installers yet) you can get it from SVN and try out the tools inside the TVTK package. Some preliminary information is available here (I'll update the pages over the next week):
http://www.enthought.com/enthought/wiki/TVTK
There are links to papers and presentations on TVTK there. With TVTK's mlab module (enthought.tvtk.tools.mlab) you can create simple visualizations with pure Numeric/numarray data. It is like mayavi.tools.imv but a lot better with many more features. I'll announce this as soon as I have written a little more documentation on installation of the enthought tool suite and a better TVTK web page. Hopefully that will happen by next week. If you are interested to check it out right away, it might be a good idea to just read the EuroPython2005 paper and presentation at the above site.
cheers, prabhu
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
Ryan Krauss wrote:
Prabhu,
I would be really interested in getting eps/pdf output. How hard would it be to get this working in Windows?
Have you tried ReportLab? http://www.reportlab.org/ Bill
I was speaking of pdf output of 3D visualizations. I would use LaTeX for the actual report generation. Ryan Bill Dandreta wrote:
Ryan Krauss wrote:
Prabhu,
I would be really interested in getting eps/pdf output. How hard would it be to get this working in Windows?
Have you tried ReportLab?
Bill
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
"Ryan" == Ryan Krauss <ryanfedora@comcast.net> writes:
Ryan> Prabhu, I would be really interested in getting eps/pdf Ryan> output. How hard would it be to get this working in Ryan> Windows? If you use the updated VTK-Python zip file that is available here: http://mayavi.sourceforge.net/dwnld/vtk/win32/VTK-Python-4.4.zip then gl2ps support should be available. The new MayaVi-1.5 installer does have gl2ps support. The above zip file is made using Enthon's latest VTK dlls. Earlier versions did not support gl2ps but the one I sited in my previous mail does support gl2ps. So, if you install this version of VTK and then save a mayavi image via gl2ps (there is a menu option for this) you should get vector EPS/PDF output. Ryan> I don't even mind if the drawing part of the figure is Ryan> somewhat pixelated, I just think it looks bad when the axes Ryan> and labels aren't type set well. By default vtk's gl2ps exporter dumps every primitive that it can (it can't do image actors though) as a vector graphic. However for complex visualizations you can turn on the 'Write3DPropsAsRasterImage' on then all 3d primitives are dumped as an image and all 2d primitives (like text) will be rendered as vector graphics. For example, try gl2ps on the heart.mv example. It will take a while to write but should work. HTH. cheers, prabhu
On 2005-09-28, Yaroslav Bulatov <yaroslavvb@gmail.com> wrote:
There are so many 3d plotting packages, but I'm looking for something simple that'll resemble 3d plots of Gnuplot/Mathematica, can someone recommend one?
I've found that Gnuplot does a very good job of resembling Gnuplot. ;) http://gnuplot-py.sourceforge.net/ -- Grant Edwards grante Yow! My EARS are GONE!! at visi.com
participants (7)
-
Bill Dandreta -
Christian Kristukat -
Grant Edwards -
Lance Boyle -
Prabhu Ramachandran -
Ryan Krauss -
Yaroslav Bulatov