I've been playing around with pythreejs, and, while it seems to be a good solution to the problem of visualizing 3D graphics in a jupyter notebook, I haven't been able to find any documentation about what jupyter is actually doing under the hood or what API exists for managing the widget. Currently, when I make a pythreejs plot (e.g., by calling display() on a pythreejs.Renderer object), I get a tiny little output window. How can I edit the size (and other properties) of this window? How can I see what the properties are?
Thanks!
I discovered by experimentation that this can be controlled by passing the width and height parameters to the pythreejs.Renderer constructor. I would, however, appreciate any answer that points me toward better documentation for pythreejs or some philosophy regarding why/how certain aspects of the three.js API were modified for Python's API.
Related
I'm trying to show a 3D image (a sphere) with a texture that contains some information. I need to rotate and zoom in/out the image.
I just came up using glumply and I saw some examples that are very helpful (especially the Earth rendering example at https://github.com/glumpy/glumpy/blob/master/examples/earth.py).
However, so far I haven't been able to find any example at all that zooms in/out the image. Does anybody know whether that's possible or not? I'm starting to think that it is not possible, but that's somehow hard to believe. I would really appreciate any example of how to do it (or somebody who knows about it telling me that it's impossible). I just discovered glumpy yesterday night, so the more complete the example, the better.
Thanks a lot!
EDIT: As far as I have seen, both the Trackball and Arcball classes (which I use for the 3D sphere) have an on_mouse_scroll method which should already zoom in/out when the mouse wheel is turned. However, that method is never called when I turn the wheel. I'm not sure whether this has something to do with a message I get in the console when I execute the program:
[w] Backend (<module 'glumpy.app.window.backends.backend_glfw' from 'C:\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_glfw.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_pyglet' from 'C:\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_pyglet.py'>) not available
Any ideas? I'm using Windows 10 and Python 3.7.
The problem was that I was lacking the GLFW DLL library. I could create the sphere and rotate it, but I couldn't zoom in/out. I didn't pay much attention to a couple of warnings/errors that I got when I executed the application as it somehow seemed to work alright.
As jdehesa pointed out in his comments, I had not properly followed the installation steps shown in Step-by-step install for x64 bit Windows 7,8, and 10.
Now it works. Thanks jdehesa!
I am developing a wxpython project where I am drawing a diagram on to a panel that I need to be able to zoom in/out to this diagram(a directed acyclic graph in my case). I will achieve this by mouse scroll when the cursor is on the panel, however that is not a part of my question. I need an advice from an experienced person about the method I am using for zooming. So far I thought as doing,
There are lines, rectangles and texts inside rectangles within this diagram. So maybe I could increase/decrease their length/size with the chosen mouse event. But it is hard to keep it balanced because rectangles are connected with lines their angles should not change, and texts inside the rectanges should stay in the middle of them.
Other method I thought of doing is to search for a built-in zoom method. Which I heard about something like Scale. However I have some questions about this method. Will this work on vector drawings(like mine) rather than images. And will it be scaling only the panel I chose and not the whole screen ? After I hear your advice about this, I will look deeper into this, but now I am a bit clueless.
Sorry if my question is too theoretical. But I felt I needed help in the area. Thanks in advance.
Note: Zooming not necessarily applied by scrolling.
Note2: My research also led me to FloatCanvas. Is this suitable to my needs ?
Yes, from your description FloatCanvas would certainly meet your needs.
Another possibility to consider would be the wx.GraphicsContext and related classes. It is vector-based (instead of raster) and supports the use of a transformation matrix which would make zooming, rotating, etc. very easy. However, the actual drawing and management of the shapes and such would probably require more work for you than using FloatCanvas.
It's all in the title: I would like to make red-cyan anaglyphs (you know, these pictures you use coloured glasses to see in 3D) of simple shapes (like points3d plots) with Mayavi. Is there such a feature? Otherwise, would you have any advice for implementing it?
EDIT : Okay, that was simple: just hit '3' in the interactive window and this sets the stereoscopic mode on. However I'd be interested in ways to configure this option, which does not seem to be documented.
Yes the interactive renderer is very poorly documented. A lot of mayavi is very badly documented, but at the least the code is often well written to figure stuff out.
Programatically you can adjust it by editing scene.render_window.stereo_render.
The source code of tvtk InteractiveRenderStyle has the following comment, also:
Some systems support crystal Eyes LCD stereo glasses; you have to invoke
set_stereo_type_to_crystal_eyes() on the rendering window.
For more configuration, you'd probably have to read the tvtk source.
I am required to use Python for engineering project. Need to create many graphs, including surface plots. In the past I used Matlab for plotting and really liked it. I was wandering if there is a module/package/extension which bring similar capability into Python.
To be more specific, I need piloting for 2 different reasons.
To understand how functions behave. Something quick and dirty would do it.
Publication/presentation. Ability to add labels, legend, grid, customise colour, axis properties etc.
Try matplotlib, it's pretty extensive and has a shell similar to MATLAB / Mathematica.
I suspect matplotlib.pyplot would be right up your alley.
I have a large data set of tuples containing (time of event, latitude, longitude) that I need to visualize. I was hoping to generate a 'movie'-like xy-plot, but was wondering if anyone has a better idea or if there is an easy way to do this in Python?
Thanks in advance for the help,
--Leo
get matplotlib
The easiest option is matplotlib. Two particular solutions that might work for you are:
1) You can generate a series of plots, each a snapshot at a given time. These can either be displayed as a dynamic plot in matplotlib, where the axes stay the same and the data moves around; or you can save the series of plots to separate files and later combine them to make a movie (using a separate application). There a number of examples in the official examples for doing these things.
2) A simple scatter plot, where the colors of the circles changes with time might work well for your data. This is super easy. See this, for example, which produces this figure
alt text http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/ellipse_collection.hires.png
I'd try rpy. All the power of R, from within python.
http://rpy.sourceforge.net/
rpy is awesome.
Check out the CRAN library for animations,
http://cran.r-project.org/web/packages/animation/index.html
Of course, you have to learn a bit about R to do this, but if you're planning to do this kind of thing routinely in future it will be well worth your while to learn.
If you are interested in scientific plotting using Python then have a look at Mlab: http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/mlab.html
It allows you to plot 2d / 3d and animate your data and the quality of the charts is really high.
Enthought's Chaco is designed for interactive/updating plots. the api and such takes a little while to get use to, but once you're there it's a fantastic framework to work with.
I have had reasonable success with Python applications generating SVG with animation features embedded, but this was with a smaller set of elements than what you probably have. For example, if your data is about a seismic event, show a circle that shows up when the event happened and grows in size matching the magnitude of the event. A moving indicator over a timeline is really simple to add.
Kaleidoscope (Opera, others maybe, Safari not) shows lots of pieces moving around and I found inspirational. Lots of other good SVG tutorial content on the site too.
You might want to look at PyQwt. It's a plotting library which works with Qt/PyQt.
Several of the PyQwt examples (in the qt4examples directory) show how to create "moving" / dynamically changing plots -- look at CPUplot.py, MapDemo.py, DataDemo.py.