"Thomas =?iso | 16 Jul 23:54

Modify surf output (axes, scaling)

Hello everyone,
I recently started using mayavi2 (and I'm also kind of new to python, couple of months), and now I'm "stuck" with a couple of (hopefully trivial) problems.
The problem is this: I'm plotting a particle density over a small area, using enthought.mayavi.mlab.surf. Now I can either call the method with
>>> surf(my_data)       #method a)
where my_data is a two dimensional numpy.ndarray containing the density, or with
>>> surf(x,y,my_data)             #method b)
where x and y are declared via numpy.mgrid so that the coordinates represent the physical coordinates instead of just [1,2,3,... ] as in the first case.
Now, with either method, I have the problem when the values of the x,y coordinates are of a different magnitude (i.e. much bigger/smaller) as the value of the z- (i.e. my_data)-coordinate. (For example, x,y being micrometer --> around 1.e-6 while z is around 1e4, or x,y being [1,2,3,...] while z is ~1e-10) So when I view the plot, I get either a thin line when my_data is much bigger than x,y; or I get a flat plane when my_data is negligible compared to x,y. Only when they by chance happen to have the same magnitude, the 3d outline is a nice cuboid.
A solution is to use the "WarpScalar" filter to shrink/expand the z-axis, but then the values also change, and the z-axis becomes useless. It's also possible to change the "Spacing" for x,y (changing z seems to be broken for me here) in the "Array2DSource" object editor, but then the x,y values become incorrect. So, my question is: How can I change the height of a graph without changing the values?
(Minimum working example: from numpy import zeros;from enthought.mayavi.mlab import surf;g=numpy.zeros((2,2));g[0][0]=1e5;surf(g) )
 
The second problem is somewhat related. Using method b) from above, when my grid has the extension of 1e-5 or so, it becomes hard to zoom in and turn the plot, and there are graphical glitches (see http://i34.tinypic.com/2efi876.png , 600kb png). This happens even when the origin of the source object is at (0,0,0). Sometimes, the plot is also kind of "jagged". So my question is: how can I produce a decent plot when the x,y grid is very small?
(Example: from numpy import zeros,mgrid;from enthought.mayavi.mlab import surf;x,y=mgrid[0:3e-5:10j,0:3e-5:10j];g=zeros((10,10));surf(x,y,g)     #you'll have to click "obtain an isometric view" and then move the mouse around a bit to find the surface)
 
Thanks in advance, cheers
 
Thomas
 
ps. I just want to recommend www.pythonxy.com for anyone who wants to quickly install mayavi2 and pretty much every other python environment that's useful for scientific applications.
_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Gael Varoquaux | 17 Jul 02:29

Re: Modify surf output (axes, scaling)

On Wed, Jul 16, 2008 at 11:57:56PM +0200, Thomas Königstein wrote:
>    Now, with either method, I have the problem when the values of the x,y
>    coordinates are of a different magnitude (i.e. much bigger/smaller) as the
>    value of the z- (i.e. my_data)-coordinate. (For example, x,y being
>    micrometer --> around 1.e-6 while z is around 1e4, or x,y being
>    [1,2,3,...] while z is ~1e-10) So when I view the plot, I get either a
>    thin line when my_data is much bigger than x,y; or I get a flat plane when
>    my_data is negligible compared to x,y. Only when they by chance happen to
>    have the same magnitude, the 3d outline is a nice cuboid.
>    A solution is to use the "WarpScalar" filter to shrink/expand the z-axis,
>    but then the values also change, and the z-axis becomes useless. It's also
>    possible to change the "Spacing" for x,y (changing z seems to be broken
>    for me here) in the "Array2DSource" object editor, but then the x,y values
>    become incorrect. So, my question is: How can I change the height of a
>    graph without changing the values?

The good answer is that the latest version of Mayavi (2.2, in ETS 2.8)
added a "scale_z" argument that controls the scale of the z axis to do
what you want. By default it auto scales your data. It is not yet in
python(x,y), sorry. You might want to ask Pierre to update python(x,y)

Now what you can do in the mean time is sue the extents keyword argument,
say if you want an 1,1,1 aspect ratio use:

mlab.surf(my_data, extent=[0, 1, 0, 1, 0, 1])

Try this out, and tell us if it does the tric.

Cheers,

Gaël

PS: Another nice way of getting Mayavi2 and Co is to use the enthought
python distribution (www.enthought.com/products/epddownload.php)
"Thomas =?iso | 17 Jul 12:27

Re: Modify surf output (axes, scaling)

Hi Gaël, thanks for the quick reply.

The extent() trick did do something, but not what I wanted :/ the surface was black instead of colored according to the lut parameter, and the axes still had the original size, see http://i37.tinypic.com/axi1p0.png (this time the colors were ok again, weird).

So I went and asked Pierre at http://groups.google.com/group/pythonxy/browse_thread/thread/df73bd57fbe9d698?hl=en about the update, and he told me that I should ask here for the new binaries, as they are not yet available on http://code.enthought.com/enstaller/eggs/windows/xp/ . So, can you maybe put them online? :)

And that EPD package looks really nice, thanks for the link. This should be featured more prominently on the main page ( https://svn.enthought.com/enthought/wiki/MayaVi#Installation )... when I tried to instally mayavi2, it took several hours and lots of dead links to get it installed, and afterwards I didn't remember how exactly I did it. The problem was that all of the packages and concepts associated with the installation (vtk,tvtk,traits,setuptools,eggs,...) were completely new to me (and some servers were down). For a complete beginner, I think it's nice to just install a .exe file and forget about the details. I now added a small paragraph on EPD on the wiki...I hope you don't mind me putting the python(x,y) link there.

By the way, does the EPD distribution also feature a python editor (IDLE)? If yes, can I create a TVTK scene from the IDLE interactive console there (does it support wxPython threading system)?

Greetings,

Thomas

Ps. Any ideas on the other problem, with the small x,y values? This is by far not as important as the other issue, as the plots are still useful and I can simply give the coordinates in micrometers so they are around 1e0, but still it would be nice to have the option to use small x,y :)


On Thu, Jul 17, 2008 at 02:29, Gael Varoquaux <gael.varoquaux <at> normalesup.org> wrote:
On Wed, Jul 16, 2008 at 11:57:56PM +0200, Thomas Königstein wrote:
>    Now, with either method, I have the problem when the values of the x,y
>    coordinates are of a different magnitude (i.e. much bigger/smaller) as the
>    value of the z- (i.e. my_data)-coordinate. (For example, x,y being
>    micrometer --> around 1.e-6 while z is around 1e4, or x,y being
>    [1,2,3,...] while z is ~1e-10) So when I view the plot, I get either a
>    thin line when my_data is much bigger than x,y; or I get a flat plane when
>    my_data is negligible compared to x,y. Only when they by chance happen to
>    have the same magnitude, the 3d outline is a nice cuboid.
>    A solution is to use the "WarpScalar" filter to shrink/expand the z-axis,
>    but then the values also change, and the z-axis becomes useless. It's also
>    possible to change the "Spacing" for x,y (changing z seems to be broken
>    for me here) in the "Array2DSource" object editor, but then the x,y values
>    become incorrect. So, my question is: How can I change the height of a
>    graph without changing the values?

The good answer is that the latest version of Mayavi (2.2, in ETS 2.8)
added a "scale_z" argument that controls the scale of the z axis to do
what you want. By default it auto scales your data. It is not yet in
python(x,y), sorry. You might want to ask Pierre to update python(x,y)

Now what you can do in the mean time is sue the extents keyword argument,
say if you want an 1,1,1 aspect ratio use:

mlab.surf(my_data, extent=[0, 1, 0, 1, 0, 1])

Try this out, and tell us if it does the tric.

Cheers,

Gaël

PS: Another nice way of getting Mayavi2 and Co is to use the enthought
python distribution (www.enthought.com/products/epddownload.php)

_______________________________________________
Enthought-dev mailing list
Enthought-dev-oRDGkvazHdbtRgLqZ5aouw@public.gmane.orgought.com
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Dave Peterson | 17 Jul 17:10

Re: Modify surf output (axes, scaling)

Thomas Königstein wrote:
>
> By the way, does the EPD distribution also feature a python editor 
> (IDLE)? If yes, can I create a TVTK scene from the IDLE interactive 
> console there (does it support wxPython threading system)?
>

EPD does indeed include IDLE and another editor called SciTe -- both can 
be launched from within the start menu.   And yes, EPD does support 
wxPython.   BTW, for an interactive console, have you tried out IPython 
(which is also in EPD).

-- Dave
Gael Varoquaux | 17 Jul 19:08

Re: Modify surf output (axes, scaling)

On Thu, Jul 17, 2008 at 10:10:45AM -0500, Dave Peterson wrote:
> EPD does indeed include IDLE and another editor called SciTe -- both can 
> be launched from within the start menu.   And yes, EPD does support 
> wxPython. 

Hum, doesn't IDLE crash on start of wx mainloop (as it relies on Tk)?

Cheers,

Gaël
Dave Peterson | 17 Jul 19:15

Re: Modify surf output (axes, scaling)

Gael Varoquaux wrote:
On Thu, Jul 17, 2008 at 10:10:45AM -0500, Dave Peterson wrote:
EPD does indeed include IDLE and another editor called SciTe -- both can be launched from within the start menu. And yes, EPD does support wxPython.
Hum, doesn't IDLE crash on start of wx mainloop (as it relies on Tk)?

Actually, I know nothing about IDLE as I don't use it.  I just meant that EPD includes wxPython.

-- Dave

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
"Thomas =?iso | 18 Jul 10:41

Re: Modify surf output (axes, scaling)

Hi again. I tried to pass the extent argument to the axes, but as a result the program breaks. Here's what I did:

from enthought.mayavi.mlab import surf,axes;from numpy import zeros;g=zeros((5,5));g[0][0]=1e5;plott=surf(g,extent=[0,3,0,3,0,6]);plott.name="p336";axes(name="p336",extent=[0,3,0,3,0,6])

Frame Based Inspector says "Exception: 'Axes' object has no attribute 'actor'", pointing at the mayvi tools.py (def _set_extent method)

Did I miss something? And, again, how can I/Pierre from pythonxy update mayavi2 to version 2.8? It's not on http://code.enthought.com/enstaller/eggs/windows/xp/ or in the EPD package...

Thumbs up

Thomas


On Thu, Jul 17, 2008 at 19:15, Dave Peterson <dpeterson-SCgzsaguwNrby3iVrkZq2A@public.gmane.org> wrote:
Gael Varoquaux wrote:
On Thu, Jul 17, 2008 at 10:10:45AM -0500, Dave Peterson wrote:
EPD does indeed include IDLE and another editor called SciTe -- both can be launched from within the start menu. And yes, EPD does support wxPython.
Hum, doesn't IDLE crash on start of wx mainloop (as it relies on Tk)?

Actually, I know nothing about IDLE as I don't use it.  I just meant that EPD includes wxPython.

-- Dave


_______________________________________________
Enthought-dev mailing list
Enthought-dev-oRDGkvazHdacsI7C1d+pp9BPR1lH4CV8@public.gmane.org
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Gael Varoquaux | 18 Jul 16:57

Re: Modify surf output (axes, scaling)

On Fri, Jul 18, 2008 at 10:41:54AM +0200, Thomas Königstein wrote:
>    Hi again. I tried to pass the extent argument to the axes, but as a result
>    the program breaks. Here's what I did:

>    from enthought.mayavi.mlab import surf,axes;from numpy import
>    zeros;g=zeros((5,5));g[0][0]=1e5;plott=surf(g,extent=[0,3,0,3,0,6]);[1]plott.name="p336";axes(name="p336",extent=[0,3,0,3,0,6])

>    Frame Based Inspector says "Exception: 'Axes' object has no attribute
>    'actor'", pointing at the mayvi tools.py (def _set_extent method)

>    Did I miss something? 

No :(. This is a bug we fixed recently. I had forgotten about it.

>    And, again, how can I/Pierre from pythonxy update mayavi2 to version
>    2.8? It's not on
>    [2]http://code.enthought.com/enstaller/eggs/windows/xp/ or in the
>    EPD package...

I can't help you here. I don't have a windows box available right now (I
am travelling), and anyhow, I really don't know how to build these
packages under windows. I know Pierre tried, and failed when it came to
building kiva.

What we can do, is try to backport these modifications. I have attached a
"decorations.py", which you should put in you
"python25/lib/site-packages/enthought.mayavi/enthought/mayavi/tools/"
directory (backup the existing decorations.py, just in case this break
everything). Hopefully this will get axes working properly. I haven't had
time to have a look at this closely, and I must run right now.

Cheers,

Gaël
"""
Functions for adding decorations (axes, colorbar, outlines..) to the
pipeline in a procedural way.
"""

# Author: Gael Varoquaux 
# Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.

# Standard library imports.
import numpy

# Enthought library imports.
import enthought.mayavi.modules.api as modules
from enthought.traits.api import String, CFloat, Instance, HasTraits, \
            Trait, CArray
import tools
from figure import draw, gcf
import types

# Mayavi imports
from pipe_base import make_function
from modules import ModuleFactory
from config import get_engine

#############################################################################
# Colorbar related functions

def _orient_colorbar(colorbar, orientation):
    """Orients the given colorbar (make it horizontal or vertical).
    """
    if orientation == "vertical":
        colorbar.orientation = "vertical"
        colorbar.width = 0.1
        colorbar.height = 0.8
        colorbar.position = (0.01, 0.15)
    elif orientation == "horizontal":
        colorbar.orientation = "horizontal"
        colorbar.width = 0.8
        colorbar.height = 0.17
        colorbar.position = (0.1, 0.01)
    else:
        print "Unknown orientation"
    draw()

def scalarbar(object=None, title=None, orientation=None):
    """Adds a colorbar for the scalar color mapping of the given object.

    If no object is specified, the first object with scalar data in the scene 
    is used.

    **Keyword arguments**:

        :object: Optional object to get the scalar color map from

        :title: The title string 

        :orientation: Can be 'horizontal' or 'vertical'
    """
    module_manager = tools._find_module_manager(object=object, 
                                                    data_type="scalar")
    if module_manager is None:
        return
    if not module_manager.scalar_lut_manager.show_scalar_bar:
        if title is None:
            title = ''
        if orientation is None:
            orientation = 'horizontal'
    colorbar = module_manager.scalar_lut_manager.scalar_bar
    if orientation is not None:
        _orient_colorbar(colorbar, orientation)
    module_manager.scalar_lut_manager.show_scalar_bar = True
    if title is not None:
        colorbar.title = title
        draw()
    return colorbar

def vectorbar(object=None, title=None, orientation=None):
    """Adds a colorbar for the vector color mapping of the given object.

    If no object is specified, the first object with vector data in the scene 
    is used.

    **Keyword arguments**
    
        :object: Optional object to get the vector color map from

        :title: The title string 

        :orientation: Can be 'horizontal' or 'vertical'
    """
    module_manager = tools._find_module_manager(object=object, 
                                                    data_type="vector")
    if module_manager is None:
        return
    if not module_manager.vector_lut_manager.show_scalar_bar:
        if title is None:
            title = ''
        orientation = 'horizontal'
    colorbar = module_manager.vector_lut_manager.scalar_bar
    module_manager.vector_lut_manager.show_scalar_bar = True
    if orientation is not None:
        _orient_colorbar(colorbar, orientation)
    if title is not None:
        colorbar.title = title
        draw()
    return colorbar

def colorbar(object=None, title=None, orientation=None):
    """Adds a colorbar for the color mapping of the given object. 

    If the object has scalar data, the scalar color mapping is 
    represented. Elsewhere the vector color mapping is represented, if 
    available.
    If no object is specified, the first object with a color map in the scene 
    is used.

    **Keyword arguments**:

        :object: Optional object to get the color map from

        :title: The title string 

        :orientation: Can be 'horizontal' or 'vertical'
    """
    colorbar = scalarbar(object=object, title=title, orientation=orientation)
    if colorbar is None:
        colorbar = vectorbar(object=object, title=title, orientation=orientation)
    return colorbar

#############################################################################
class SingletonModuleFactory(ModuleFactory):
    """ Base classe for factories that can find an existing object
    matching certain criteria instead of building a new one"""

    def __init__(self, *args, **kwargs):
        """ Try to find an module actor with the same name, on the given 
        parent (if any) and use it rather than building a new module."""
        # Call the HasTraits constructor, but not the PipeBase one.
        HasTraits.__init__(self)
        self._scene = gcf()
        self._engine = get_engine() 
        self._scene.scene.disable_render = True
        # Process the arguments
        if len(args)==1:
            (parent, ) = args
        elif len(args)==0:
            parent = None
        else:
            raise ValueError, "Wrong number of arguments"

        # Try to find an existing module, if not add one to the pipeline
        if parent == None:
            target = self._scene
        else:
            target = parent

        klass = self._target.__class__

        for obj in tools._traverse(target):
            if ( isinstance(obj, klass)
                        and obj.name == self.name ):
                self._target = obj
                break
        else:
            self._engine.add_module(self._target, obj=parent)

        # Now calling the traits setter, so that traits handlers are
        # called
        self.set(**kwargs)
        #self._scene.scene.reset_zoom()
        self._scene.scene.disable_render = False

#############################################################################
class AxesLikeModuleFactory(SingletonModuleFactory):
    """ Base class for axes and outline"""

    extent = CArray(shape=(6,),
                    help="""[xmin, xmax, ymin, ymax, zmin, zmax]
                            Default is the object's extents.""", )

    def _extent_changed(self):
        """ There is no universal way of setting extents for decoration
            objects. This should be implemented in subclasses
        """
        pass

    # Override the color and opacity handlers: axes and outlines do not
    # behave like other modules

    def _color_changed(self):
        if self.color:
            try:
                self._target.property.color = self.color
            except AttributeError:
                try:
                    self._target.actor.property.color = self.color
                except AttributeError:
                    pass

    def _opacity_changed(self):
        try:
            self._target.property.opacity = self.opacity
        except AttributeError:
            try:
                self._target.actor.property.opacity = self.opacity
            except AttributeError:
                pass

#############################################################################
class Outline(AxesLikeModuleFactory):
    """ Creates an outline for the current (or given) object."""

    _target = Instance(modules.Outline, ())

    def _extent_changed(self):
        tools._set_extent(self._target, self.extent)

outline = make_function(Outline)

#############################################################################
class Axes(AxesLikeModuleFactory):
    """ Creates axes for the current (or given) object."""

    xlabel = String(None, adapts='axes.x_label',
                help='the label of the x axis')

    ylabel = String(None, adapts='axes.y_label',
                help='the label of the y axis')

    zlabel = String(None, adapts='axes.z_label',
                help='the label of the z axis')

    ranges = Trait(None, None, CArray(shape=(6,)),
                    help="""[xmin, xmax, ymin, ymax, zmin, zmax]
                            Ranges of the labels displayed on the axes.
                            Default is the object's extents.""", )

    _target = Instance(modules.Axes, ())

    def _extent_changed(self):
        """ Code to modify the extents for 
        """
        axes = self._target
        axes.axes.use_data_bounds = False 
        axes.axes.bounds = self.extent
        if self.ranges is None:
            axes.axes.ranges = \
                axes.module_manager.source.outputs[0].bounds
            axes.axes.use_ranges = True
        else:
            print self.ranges

    def _ranges_changed(self):
        if self.ranges is not None:
            self._target.axes.ranges = self.ranges
            self._target.axes.use_ranges = True

axes = make_function(Axes)

def xlabel(text, object=None):
    """ 
    Creates a set of axes if there isn't already one, and sets the x label

    **Keyword arguments**:

        :object:  The object to apply the module to, if not the whole scene
                  is searched for a suitable object.
    """
    return axes(object, xlabel=text)

def ylabel(text, object=None):
    """ 
    Creates a set of axes if there isn't already one, and sets the y label

    **Keyword arguments**:

    
        :object:  The object to apply the module to, if not the whole scene
                  is searched for a suitable object.
    """
    return axes(object, ylabel=text)

def zlabel(text, object=None):
    """ 
    Creates a set of axes if there isn't already one, and sets the z label

    **Keyword arguments**
    
        :object:  The object to apply the module to, if not the whole scene
                  is searched for a suitable object.
    """
    return axes(object, zlabel=text)

##############################################################################
class OrientationAxesFactory(SingletonModuleFactory):
    """Applies the OrientationAxes mayavi module to the given VTK data object.
    """

    xlabel = String(None, adapts='axes.x_axis_label_text',
                help='the label of the x axis')

    ylabel = String(None, adapts='axes.y_axis_label_text',
                help='the label of the y axis')

    zlabel = String(None, adapts='axes.z_axis_label_text',
                help='the label of the z axis')

    _target = Instance(modules.OrientationAxes, ())

orientationaxes = make_function(OrientationAxesFactory)

###############################################################################
class Text(ModuleFactory):
    """ Adds a text on the figure.

        **Function signature**::

            text(x, y, text, ...) 

        x, and y are the position of the origin of
        the text on the 2D projection of the figure.
        """

    width = Trait(None, None, CFloat, adapts='width',
                        help="""width of the text.""")

    _target = Instance(modules.Text, ())

    def __init__(self, x, y, text, **kwargs):
        """ Override init as for diffreent positional arguments."""
        super(Text, self).__init__(None, **kwargs)
        self._target.text       = text
        self._target.x_position = x
        self._target.y_position = y

text = make_function(Text)

#############################################################################
class Title(SingletonModuleFactory):
    """Creates a title for the figure.

    **Function signature**:: 

        title(text, ...)

    """

    size = CFloat(1, help="the size of the title")

    height = CFloat(0.8, adapts='y_position',
                         help="""height of the title, in portion of the 
                                 figure height""")

    def _size_changed(self):
        self._target.width = min(0.05*self.size*len(self._text), 1)
        self._target.x_position = 0.5*(1 - self._target.width)

    _target = Instance(modules.Text)

    def __target_default(self):
        """ This is called only if no existing title is found."""
        width = min(0.05*self.size*len(self._text), 1)
        text= modules.Text(text=self._text, 
                            y_position=self.height,
                            x_position=0.5*(1 - width),)
        text.width =width
        return text

    def __init__(self, text, **kwargs):
        self._text = text # This will be used by _size_changed 
        super(Title, self).__init__(**kwargs)
        self._target.text = self._text

title = make_function(Title)

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
"Thomas =?iso | 22 Jul 23:10

Re: Modify surf output (axes, scaling)

Thanks Gael. Pierre already supplied me with a ETS 2.8 build, the decorations.py is identical to the one you attatched in your mail.

Now, the plot looks better in terms of aspect ratio, but the axes don't fit: http://i37.tinypic.com/2jayljn.png <- the values go from 0 to 50, but the axes obviously are too large. (to reconstruct: "from numpy import array;from enthought.mayavi.mlab import surf;surf(array([[x*x+y*y for x in range(-5,5)] for y in range(-5,5)]))" )

Also,is it possible to activate some kind of polynomial/spline interpolation instead of linear? the enthought.tvtk.tools.mlab.SurfRegular method seems to do this: http://i35.tinypic.com/2wnyb2a.png <- the surface looks more "smooth"

Anyways, thanks again, cheers

Thomas




On Fri, Jul 18, 2008 at 16:57, Gael Varoquaux <gael.varoquaux-t+5nXNeJE7o5viHyz3+zKA@public.gmane.org> wrote:
On Fri, Jul 18, 2008 at 10:41:54AM +0200, Thomas Königstein wrote:
>    Hi again. I tried to pass the extent argument to the axes, but as a result
>    the program breaks. Here's what I did:

>    from enthought.mayavi.mlab import surf,axes;from numpy import
>    zeros;g=zeros((5,5));g[0][0]=1e5;plott=surf(g,extent=[0,3,0,3,0,6]);[1]plott.name="p336";axes(name="p336",extent=[0,3,0,3,0,6])

>    Frame Based Inspector says "Exception: 'Axes' object has no attribute
>    'actor'", pointing at the mayvi tools.py (def _set_extent method)

>    Did I miss something?

No :(. This is a bug we fixed recently. I had forgotten about it.

>    And, again, how can I/Pierre from pythonxy update mayavi2 to version
>    2.8? It's not on
>    [2]http://code.enthought.com/enstaller/eggs/windows/xp/ or in the
>    EPD package...

I can't help you here. I don't have a windows box available right now (I
am travelling), and anyhow, I really don't know how to build these
packages under windows. I know Pierre tried, and failed when it came to
building kiva.

What we can do, is try to backport these modifications. I have attached a
"decorations.py", which you should put in you
"python25/lib/site-packages/enthought.mayavi/enthought/mayavi/tools/"
directory (backup the existing decorations.py, just in case this break
everything). Hopefully this will get axes working properly. I haven't had
time to have a look at this closely, and I must run right now.

Cheers,

Gaël

_______________________________________________
Enthought-dev mailing list
Enthought-dev-oRDGkvazHdbtRgLqZ5aouw@public.gmane.orgought.com
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
"Thomas =?iso | 28 Jul 02:00

Re: Modify surf output (axes, scaling)

Hi again. In the ETS 2.8 version (don't know if it was there in the old one as well), there is a "ranges" keyword in the axes function, which lets me arbitrarily set the axes values. So this problem is (not very elegantly, but still) solved.

So, about the other thing (mostly eye-candy :) ) is it possible to produce "smooth" surfaces as with SurfRegular? ( http://i35.tinypic.com/2wnyb2a.png vs http://i37.tinypic.com/2jayljn.png )

Thanks, cheers

Thomas

On Tue, Jul 22, 2008 at 23:10, Thomas Königstein <thkoe002-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Thanks Gael. Pierre already supplied me with a ETS 2.8 build, the decorations.py is identical to the one you attatched in your mail.

Now, the plot looks better in terms of aspect ratio, but the axes don't fit: http://i37.tinypic.com/2jayljn.png <- the values go from 0 to 50, but the axes obviously are too large. (to reconstruct: "from numpy import array;from enthought.mayavi.mlab import surf;surf(array([[x*x+y*y for x in range(-5,5)] for y in range(-5,5)]))" )

Also,is it possible to activate some kind of polynomial/spline interpolation instead of linear? the enthought.tvtk.tools.mlab.SurfRegular method seems to do this: http://i35.tinypic.com/2wnyb2a.png <- the surface looks more "smooth"

Anyways, thanks again, cheers

Thomas




On Fri, Jul 18, 2008 at 16:57, Gael Varoquaux <gael.varoquaux-t+5nXNeJE7o5viHyz3+zKA@public.gmane.org> wrote:
On Fri, Jul 18, 2008 at 10:41:54AM +0200, Thomas Königstein wrote:
>    Hi again. I tried to pass the extent argument to the axes, but as a result
>    the program breaks. Here's what I did:

>    from enthought.mayavi.mlab import surf,axes;from numpy import
>    zeros;g=zeros((5,5));g[0][0]=1e5;plott=surf(g,extent=[0,3,0,3,0,6]);[1]plott.name="p336";axes(name="p336",extent=[0,3,0,3,0,6])

>    Frame Based Inspector says "Exception: 'Axes' object has no attribute
>    'actor'", pointing at the mayvi tools.py (def _set_extent method)

>    Did I miss something?

No :(. This is a bug we fixed recently. I had forgotten about it.

>    And, again, how can I/Pierre from pythonxy update mayavi2 to version
>    2.8? It's not on
>    [2]http://code.enthought.com/enstaller/eggs/windows/xp/ or in the
>    EPD package...

I can't help you here. I don't have a windows box available right now (I
am travelling), and anyhow, I really don't know how to build these
packages under windows. I know Pierre tried, and failed when it came to
building kiva.

What we can do, is try to backport these modifications. I have attached a
"decorations.py", which you should put in you
"python25/lib/site-packages/enthought.mayavi/enthought/mayavi/tools/"
directory (backup the existing decorations.py, just in case this break
everything). Hopefully this will get axes working properly. I haven't had
time to have a look at this closely, and I must run right now.

Cheers,

Gaël



_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Gael Varoquaux | 28 Jul 02:30

Re: Modify surf output (axes, scaling)

On Mon, Jul 28, 2008 at 02:00:49AM +0200, Thomas Königstein wrote:
>    Hi again. In the ETS 2.8 version (don't know if it was there in the old
>    one as well), there is a "ranges" keyword in the axes function, which lets
>    me arbitrarily set the axes values. So this problem is (not very
>    elegantly, but still) solved.

>    So, about the other thing (mostly eye-candy :) ) is it possible to produce
>    "smooth" surfaces as with SurfRegular? (
>    [1]http://i35.tinypic.com/2wnyb2a.png vs
>    [2]http://i37.tinypic.com/2jayljn.png )

Hi Thomas,

I haven't forgotten you :). Just travelling, and dealing with other
urgent matters. I think I have an idea why the surface isn't as smooth.
Can you give me the exact command line that you are using for the surf
command.

Cheers,

Gaël

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Prabhu Ramachandran | 28 Jul 05:42

Re: Modify surf output (axes, scaling)

Gael Varoquaux wrote:
> I haven't forgotten you :). Just travelling, and dealing with other
> urgent matters. I think I have an idea why the surface isn't as smooth.
> Can you give me the exact command line that you are using for the surf
> command.

 From his original email:

"from numpy import array;from enthought.mayavi.mlab import 
surf;surf(array([[x*x+y*y for x in range(-5,5)] for y in range(-5,5)]))"

Anyway, I think surf isn't doing a compute normals before the surface 
module.  tvtk's mlab does use a normals filter.

cheers,
prabhu
Gael Varoquaux | 28 Jul 05:47

Re: Modify surf output (axes, scaling)

On Mon, Jul 28, 2008 at 09:12:07AM +0530, Prabhu Ramachandran wrote:
> "from numpy import array;from enthought.mayavi.mlab import 
> surf;surf(array([[x*x+y*y for x in range(-5,5)] for y in range(-5,5)]))"

Ooops, my bad, I could have looked that up.

> Anyway, I think surf isn't doing a compute normals before the surface 
> module.  tvtk's mlab does use a normals filter.

OK, so you think that is the difference? Do you think we should do that?
It is quite easy to add. Is there a performance issue? In which case
should we threshold on the size of the input arrays? Or give the choice
whether to add the filter or not through a keyword argument?

I am all for improving mlab :).

Gaël
fred | 28 Jul 10:02

Re: Modify surf output (axes, scaling)

Gael Varoquaux a écrit :

> OK, so you think that is the difference?
I do think, yes ;-)

> It is quite easy to add. Is there a performance issue?
I don't see any loss for a grid of 1000x1000.

  In which case
> should we threshold on the size of the input arrays? Or give the choice
> whether to add the filter or not through a keyword argument?
I always use PolyDataNormals filter ;-)
Only my 2 cts points of view.

But I'd vote for a keyword argument.

Cheers,

--

-- 
Fred
_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Gael Varoquaux | 30 Jul 19:06

Re: Modify surf output (axes, scaling)

On Mon, Jul 28, 2008 at 02:00:49AM +0200, Thomas Königstein wrote:
>    Hi again. In the ETS 2.8 version (don't know if it was there in the old
>    one as well), there is a "ranges" keyword in the axes function, which lets
>    me arbitrarily set the axes values. So this problem is (not very
>    elegantly, but still) solved.

>    So, about the other thing (mostly eye-candy :) ) is it possible to produce
>    "smooth" surfaces as with SurfRegular? (
>    [1]http://i35.tinypic.com/2wnyb2a.png vs
>    [2]http://i37.tinypic.com/2jayljn.png )

OK, Thomas, that won't solve your issue in the short term, but I just
improved the surf and mesh functions to address this. In the upcoming
release of mayavi, you'll get the same nice smooth surfaces.

Gaël

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
"Thomas =?iso | 4 Aug 16:52

Re: Modify surf output (axes, scaling)

Thanks :) until then, fred's tip with the Compute Normals filter does a pretty decent job. Still, I have some questions about this filter and some more general, small problems with mayavi2.

About the original topic: how do I apply the filter via shell? enthought.mayavi.filters.poly_data_normals.Instance(s) seems to create an instance of the filter, but it dooesn't show up in the scene explorer.

And on another note: Can I somehow change the behavior of the camera/mouse interaction? I'd like the system to rorate only about two axes, the vertical and the horizontal one. In other words, the axis which is separately activated when I press ctrl should be disabled when moving the viewport with the mouse normally. Is that possible?

Also, how can I move a glyph-plot relative to the origin of the scene (for example, from enthought.mayavi.mlab import quiver3d;from numpy import array;quiver3d(*array(range(6))) )? Moving surf-plots works by choosig Array2DSource->Data->Origin. Is there a equivalent way to do this via shell or explorer for a quiver3d plot?

Thanks again, cheers

Thomas


On Wed, Jul 30, 2008 at 19:06, Gael Varoquaux <gael.varoquaux <at> normalesup.org> wrote:
On Mon, Jul 28, 2008 at 02:00:49AM +0200, Thomas Königstein wrote:
>    Hi again. In the ETS 2.8 version (don't know if it was there in the old
>    one as well), there is a "ranges" keyword in the axes function, which lets
>    me arbitrarily set the axes values. So this problem is (not very
>    elegantly, but still) solved.

>    So, about the other thing (mostly eye-candy :) ) is it possible to produce
>    "smooth" surfaces as with SurfRegular? (
>    [1]http://i35.tinypic.com/2wnyb2a.png vs
>    [2]http://i37.tinypic.com/2jayljn.png )

OK, Thomas, that won't solve your issue in the short term, but I just
improved the surf and mesh functions to address this. In the upcoming
release of mayavi, you'll get the same nice smooth surfaces.

Gaël


_______________________________________________
Enthought-dev mailing list
Enthought-dev-oRDGkvazHdacsI7C1d+pp9BPR1lH4CV8@public.gmane.org
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Gael Varoquaux | 4 Aug 17:13

Re: Modify surf output (axes, scaling)

On Mon, Aug 04, 2008 at 04:52:40PM +0200, Thomas Königstein wrote:
>    About the original topic: how do I apply the filter via shell?
>    enthought.mayavi.filters.poly_data_normals.Instance(s) seems to create an
>    instance of the filter, but it dooesn't show up in the scene explorer.

What is your version of mayavi? With recent-enough versions of mayavi,
you can do this:

out = mlab.pipeline.polydatanormals(src)

where src is the object you want to apply your filter on, and out the
output of the filter. Note that in mayavi2, version 3.0, that we are
going to release next week, this has changed to 
pipeline.poly_data_normals

Now you will have to build the pipeline yourself if you want control on
it. The surf command boils down to:

P = mlab.pipeline
src = P.array2dsource(z)
w = P.warpscalar(src)
s = P.suface(w)

Each of these steps take keyword arguments to control their properties,
you can have a look at there docstring to find these out.

Alternatively, if you have a really old version of mayavi, you can add
retrieve the adding functions manually:

from enthought.mayavi.tools.sources import array2dsource
from enthought.mayavi.tools.filters import warpscalar
from enthought.mayavi.tools.modules import surface

Now in your oldish version of mayavi, you don't have PolyDataNormals
accessible in that way, so you have do to it the manual way:

from enthought.mayavi.filters.poly_data_normals import PolyDataNormals

p = PolyDataNormals()
w.add_filter(p)

and then you can do s = P.surface(p).

As you can see this is a part of mlab that got a fair amount of work
lately. This is alos the reason why it wasn't documented. I have only
become happy with the implementation this coming release.

>    And on another note: Can I somehow change the behavior of the camera/mouse
>    interaction? I'd like the system to rorate only about two axes, the
>    vertical and the horizontal one. In other words, the axis which is
>    separately activated when I press ctrl should be disabled when moving the
>    viewport with the mouse normally. Is that possible?

I don't know. Prabhu may know.

>    Also, how can I move a glyph-plot relative to the origin of the scene (for
>    example, from enthought.mayavi.mlab import quiver3d;from numpy import
>    array;quiver3d(*array(range(6))) )? Moving surf-plots works by choosig
>    Array2DSource->Data->Origin. Is there a equivalent way to do this via
>    shell or explorer for a quiver3d plot?

Are you looking for the extent keyword argument? I am not too sure what
you want to do, here.

HTH,

Gaël

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
"Thomas =?iso | 4 Aug 18:16

Re: Modify surf output (axes, scaling)

Wow, thanks for your elaborate reply. I'm just afraid the code you supplied doesn't work for me as w doesn't have a "add_filter" method. enthought.mayavi.version.version == 2.1.1 for me. I'll try around with the alternatives you mentioned when I have more time.

And the other thing, with the quiver3d plot, I just want to move a plot spatially. For example:

from enthought.mayavi.mlab import quiver3d;from numpy import random;a=quiver3d(*array([random.random(40) for i in range(6)]));b=quiver3d(*array([random.random(40) for i in range(6)]))

gives me two "bunches" of vectors, both at the same location. How can I now seperate one from the other?

Thanks again for the quick reply, cheers

Thomas

On Mon, Aug 4, 2008 at 17:13, Gael Varoquaux <gael.varoquaux <at> normalesup.org> wrote:
On Mon, Aug 04, 2008 at 04:52:40PM +0200, Thomas Königstein wrote:
>    About the original topic: how do I apply the filter via shell?
>    enthought.mayavi.filters.poly_data_normals.Instance(s) seems to create an
>    instance of the filter, but it dooesn't show up in the scene explorer.

What is your version of mayavi? With recent-enough versions of mayavi,
you can do this:

out = mlab.pipeline.polydatanormals(src)

where src is the object you want to apply your filter on, and out the
output of the filter. Note that in mayavi2, version 3.0, that we are
going to release next week, this has changed to
pipeline.poly_data_normals

Now you will have to build the pipeline yourself if you want control on
it. The surf command boils down to:

P = mlab.pipeline
src = P.array2dsource(z)
w = P.warpscalar(src)
s = P.suface(w)

Each of these steps take keyword arguments to control their properties,
you can have a look at there docstring to find these out.

Alternatively, if you have a really old version of mayavi, you can add
retrieve the adding functions manually:

from enthought.mayavi.tools.sources import array2dsource
from enthought.mayavi.tools.filters import warpscalar
from enthought.mayavi.tools.modules import surface

Now in your oldish version of mayavi, you don't have PolyDataNormals
accessible in that way, so you have do to it the manual way:

from enthought.mayavi.filters.poly_data_normals import PolyDataNormals

p = PolyDataNormals()
w.add_filter(p)

and then you can do s = P.surface(p).

As you can see this is a part of mlab that got a fair amount of work
lately. This is alos the reason why it wasn't documented. I have only
become happy with the implementation this coming release.

>    And on another note: Can I somehow change the behavior of the camera/mouse
>    interaction? I'd like the system to rorate only about two axes, the
>    vertical and the horizontal one. In other words, the axis which is
>    separately activated when I press ctrl should be disabled when moving the
>    viewport with the mouse normally. Is that possible?

I don't know. Prabhu may know.

>    Also, how can I move a glyph-plot relative to the origin of the scene (for
>    example, from enthought.mayavi.mlab import quiver3d;from numpy import
>    array;quiver3d(*array(range(6))) )? Moving surf-plots works by choosig
>    Array2DSource->Data->Origin. Is there a equivalent way to do this via
>    shell or explorer for a quiver3d plot?

Are you looking for the extent keyword argument? I am not too sure what
you want to do, here.

HTH,

Gaël


_______________________________________________
Enthought-dev mailing list
Enthought-dev-oRDGkvazHdacsI7C1d+pp9BPR1lH4CV8@public.gmane.org
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Gael Varoquaux | 4 Aug 18:32

Re: Modify surf output (axes, scaling)

On Mon, Aug 04, 2008 at 06:16:42PM +0200, Thomas Königstein wrote:
>    Wow, thanks for your elaborate reply.

Well, it should be a simple reply, but the problem is that you are on a
pretty old version of Mayavi, and the simple way of doing what you want
to do are simply not in your version.

> I'm just afraid the code you
>    supplied doesn't work for me as w doesn't have a "add_filter" method.
>    enthought.mayavi.version.version == 2.1.1 for me. I'll try around with the
>    alternatives you mentioned when I have more time.

Yes, sorry about that. Use the "add_child" method.

What platform are you on? It woul be nice to get you to a newer version
of Mayavi. It would make your life easier.

>    And the other thing, with the quiver3d plot, I just want to move a plot
>    spatially. For example:

>    from enthought.mayavi.mlab import quiver3d;from numpy import
>    random;a=quiver3d(*array([random.random(40) for i in
>    range(6)]));b=quiver3d(*array([random.random(40) for i in range(6)]))

>    gives me two "bunches" of vectors, both at the same location. How can I
>    now seperate one from the other?

That is what the extent keyword argument is for. Just give two extents
located in different regions. Does that make sens?

Cheers,

Gaël

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
"Thomas =?iso | 5 Aug 00:02

Re: Modify surf output (axes, scaling)

> Yes, sorry about that. Use the "add_child" method.
>
> What platform are you on? It woul be nice to get you to a newer version
> of Mayavi. It would make your life easier.

I'm on Windows XP home edition, SP2, I got this mayavi version from pythonxy.com. And yes I'd like to try a easier-to-use version of mayavi :)
In terms of usability, my problem with mayavi is that most of the time I'm trying to figure out how certain methods/functions/modules work by looking at their __doc__ and their subclasses via autocomplete or dir(...); that way I learned for example some of numpy or PIL. But in mayavi, there are always dozens of subclasses, which have no obvious use for me... enable_traits, configure_traits, tno_can_delete_me, .... most of them probably aren't meant to be used by the "end-user", but still they are there and confuse me :/

> >    And the other thing, with the quiver3d plot, I just want to move a plot
> >    spatially. For example:
>
> >    from enthought.mayavi.mlab import quiver3d;from numpy import
> >    random;a=quiver3d(*array([random.random(40) for i in
> >    range(6)]));b=quiver3d(*array([random.random(40) for i in range(6)]))
>
> >    gives me two "bunches" of vectors, both at the same location. How can I
> >    now seperate one from the other?
>
> That is what the extent keyword argument is for. Just give two extents
> located in different regions. Does that make sens?

Well, yes, but my problem was that I have an existing plot in the scene, and I want to move it after it has been created. With a Surface, this is possible by clicking on Data2DSource->Data->Origin in the scene explorer, but there is no equivalent for Vectors. There is a "Whole Extent" and "Update Extent" field, but changing their values has no effect for me.

The extent keyword works, however. I'm just not sure, how :) what does each of the six values do? I guess they construct three points which define a cuboid where the vectors are stuffed into, but I couldn't quite get it right yet.. extend(0,0,0,0,0) for example does nothing.

And another thing: in my example, I used quiver3d(*array(...)). The asterisk somehow turns an array of n arrays into n arrays, as it seems. But whereas quiver3d(*array(...)) works, a=*array(....) does not. Also, quiver3d(*array(...), extent=(..)) does not work. This is not a problem with mayavi, it's just my lack of knowledge concerning numpy. I must have read the *array thing somewhere, but now I have forgotten where that was, and googling for * isn't so easy :)

Well, thanks again for your help. Mayavi is an amazing piece of software, as you can see my critique is coming from someone with really small experience in python.

Thumbs up, bye

Thomas

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Dave Peterson | 5 Aug 00:08

Re: Modify surf output (axes, scaling)

Thomas Königstein wrote:
>
> And another thing: in my example, I used quiver3d(*array(...)). The 
> asterisk somehow turns an array of n arrays into n arrays, as it 
> seems. But whereas quiver3d(*array(...)) works, a=*array(....) does 
> not. Also, quiver3d(*array(...), extent=(..)) does not work. This is 
> not a problem with mayavi, it's just my lack of knowledge concerning 
> numpy. I must have read the *array thing somewhere, but now I have 
> forgotten where that was, and googling for * isn't so easy :)
>

IIUC, this is just standard Python syntax for expanding a list into 
positional parameters when calling a callable.  Because the syntax 
requires calling a callable, it won't work for the a=*array(...) 
tries.   To get it to work when specifying extent, do 
"quiver3d(extent=(..), *array(...)) -- * expansion must be after any 
normal positional parameters and keyword values.

-- Dave
Gael Varoquaux | 5 Aug 06:42

Re: Modify surf output (axes, scaling)

On Tue, Aug 05, 2008 at 12:02:59AM +0200, Thomas Königstein wrote:
>    I'm on Windows XP home edition, SP2, I got this mayavi version from
>    [1]pythonxy.com. And yes I'd like to try a easier-to-use version of mayavi
>    :)

Well, unfortunately I am not sure there is a newer binary for windows.
Did you check that the latest pythonxy did not have a more recent binary?
In two weeks we are going to release a fresh new EPD (Enthought Python
Distribution) that will have a bran new and shiny version of mayavi. In
the mean time you might have to do with what you have. I am certainly
totaly unable to build binaries for windows.

>    In terms of usability, my problem with mayavi is that most of the time I'm
>    trying to figure out how certain methods/functions/modules work by looking
>    at their __doc__ and their subclasses via autocomplete or dir(...); that
>    way I learned for example some of numpy or PIL. But in mayavi, there are
>    always dozens of subclasses, which have no obvious use for me...
>    enable_traits, configure_traits, tno_can_delete_me, .... most of them
>    probably aren't meant to be used by the "end-user", but still they are
>    there and confuse me :/

Are you using ipython? If you have a recent-enough version, it should
have traits-aware tab-completion, just hitting the tab key will give you
a list of meaningful attributes. I am not too sure when this came in
ipython, though looking at pythonxy I see it also has an ice-age release
of ipython. Well, I guess this is another thing that will improve in the
next release of EPD.

In the mean time, you can get updated documentation on the web, on
http://code.enthought.com/projects/mayavi/docs/development/html/
I'll change this URL real soon to
http://code.enthought.com/projects/mayavi/docs/development/mayavi/html/
by the way.

This is documentation for the developmenet version of mayavi, so some
things may not apply :).

>    > >    And the other thing, with the quiver3d plot, I just want to move a
>    plot
>    > >    spatially. For example:

>    > >    from enthought.mayavi.mlab import quiver3d;from numpy import
>    > >    random;a=quiver3d(*array([random.random(40) for i in
>    > >    range(6)]));b=quiver3d(*array([random.random(40) for i in
>    range(6)]))

>    > >    gives me two "bunches" of vectors, both at the same location. How
>    can I
>    > >    now seperate one from the other?

>    > That is what the extent keyword argument is for. Just give two extents
>    > located in different regions. Does that make sens?

>    Well, yes, but my problem was that I have an existing plot in the scene,
>    and I want to move it after it has been created. With a Surface, this is
>    possible by clicking on Data2DSource->Data->Origin in the scene explorer,
>    but there is no equivalent for Vectors. There is a "Whole Extent" and
>    "Update Extent" field, but changing their values has no effect for me.

You could use a transform data filter to tune this interactively. Maybe I
should be using this to implement the extent keyword... So many things to
do.

>    The extent keyword works, however. I'm just not sure, how :) what does
>    each of the six values do? I guess they construct three points which
>    define a cuboid where the vectors are stuffed into, but I couldn't quite
>    get it right yet.. extend(0,0,0,0,0) for example does nothing.

Yes, indeed, there is a check to check that you are not putting some
dimensions at zero. Without this check there used to be funny things
happening with flat objects. You could use extent like this:
extent = (0, 1, 0, 1, 0, 1) for one object
extent = (-1, 0, 0, 1, 0, 1) for the other.

>    And another thing: in my example, I used quiver3d(*array(...)). The
>    asterisk somehow turns an array of n arrays into n arrays, as it seems.
>    But whereas quiver3d(*array(...)) works, a=*array(....) does not. Also,
>    quiver3d(*array(...), extent=(..)) does not work. This is not a problem
>    with mayavi, it's just my lack of knowledge concerning numpy. I must have
>    read the *array thing somewhere, but now I have forgotten where that was,
>    and googling for * isn't so easy :)

Well there is a cleaner way of transforming one n*3 array in three
arrays: a[0, :], a[1, :], a[2, :]. What you are doing is actually
transforming one list-like argument to a function in several arguments to
the same function made of the elements of that list. This will work only
on function calls.

HTH,

Gaël

Re: Modify surf output (axes, scaling)

Thomas Königstein wrote:
> And on another note: Can I somehow change the behavior of the 
> camera/mouse interaction? I'd like the system to rorate only about two 
> axes, the vertical and the horizontal one. In other words, the axis 
> which is separately activated when I press ctrl should be disabled when 
> moving the viewport with the mouse normally. Is that possible?

There are a few options.

  1. You can change the interaction style of a render window interactor 
using a pre-built interactor style provided by VTK.

  2. There is a nice VTK example that demonstrates how to create your 
own interaction behavior using event handlers.  Look in 
Examples/GUI/Python/CustomInteraction.py.  It is VTK code that could 
rather easily be translated to TVTK.

Unfortunately, there isn't a simple way of doing this and at the moment 
I am completely swamped to help.  This would make for a very nice 
contribution though.  If no one else volunteers for this I can see if I 
can have a student work on this, it would be a very nice learning exercise.

cheers,
prabhu
Gael Varoquaux | 17 Jul 19:06

Re: Modify surf output (axes, scaling)

On Thu, Jul 17, 2008 at 12:27:36PM +0200, Thomas Königstein wrote:
>    The extent() trick did do something, but not what I wanted :/ the surface
>    was black instead of colored according to the lut parameter, and the axes
>    still had the original size, see [1]http://i37.tinypic.com/axi1p0.png
>    (this time the colors were ok again, weird).

Quickly (I am at a conference): the color problem is probably a bug in
your graphics card, and not something we can really do anything about.
The axes problem can be solved by passing the same extents parameter to
the axes function. You might also need to tweek the labels.

>   By the way, does the EPD distribution also feature a python editor (IDLE)?
>   If yes, can I create a TVTK scene from the IDLE interactive console there
>   (does it support wxPython threading system)?

IDLE does not support wxPython threading system. You'll crash it
immediatly if you start TVTK with it.

For the small x,y problem, I am not too sure what the solution might be.
I fear this could be a problem related to precision of an internal
representation. Changing units might be a good solution. Remember, you
can change the labels of the axes.

HTH,

Gaël

_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev

Gmane