Scaling x axis globally

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Scaling x axis globally

Tim Duly
Hi,

I'm a bit new to Mayavi2 so if I am missing an oversight, my apologies.
 Right now I have successfully loaded in data into the mayavi2 application
(for now, I am *not* plotting using scripting-- I created the data file
with help from
http://github.enthought.com/mayavi/mayavi/auto/example_structured_grid.html#example-structured-grid).


There's an issue with scaling of the x-axis.  The coordinates are in
different units: the y-axis has units of altitude, and the x-axis has units
of latitude.  To give an example, the y-axis ranges from 90 to 6000 (km),
while the x-axis only ranges from -30 to 30 (degrees).  Therefore, the
image is "smashed" together.

I found a way to resolve this in the surface plot: by editing the "actor"
under the surface module, there's an F0 scale number that I can change
which essentially stretches out the x-axis.  When I do this, the image
looks fine.

The issue I have is that this is a bit of a pain.  Let's say I wanted to
add another module: the grid for example.  I would have to change the F0
Scale number for this actor too.  And some modules, like the axis labeling
for example, I can't find how to scale.

So my question is simple: is there some sort of "global" scaling parameter
that I can set, and that way each module would be appropriately x-scaled?
 In MATLAB, this is equivalent to the "axis" command: axis([-30 30 90
6000]).

I thought I had found my answer here:
http://github.enthought.com/mayavi/mayavi/mlab.html#changing-the-scale-and-position-of-objects
,
but it's a bit confusing-- how do you do this in the mayavi2 program?

If you'd like the VTK file, feel free to let me know (I don't believe it
would go through if I attached it).

Thanks,
Tim
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Scaling x axis globally

David Ohlemacher
Hi Tim.

I would think you can write a simple script that does the warping you
require.

In my scripts, I need to scale the z axis.  I do this:

# WarpScalar: Set F2 to a larger value to exagerate elevation features.
self.plot = self.scene.mlab.surf(self.nDistXs, self.nDistYs, self.nDs,
colormap='gist_earth', warp_scale=9)

One way to figure out what to do is to use Mayavi's record feature (the
red circle on the toolbar).  Turn recording on, do what you need to do
as you are now, and you will see how it would be done from a script from
the recorder.   I should think it will give you the script you need.

I have not used the Mayavi GUI much, mostly my own scripts that use Mayavi.

Regards,
David

PS The Geod python module might be helpful.   I use it to convert lats
and longs to distances so I can plot in meters.



On 04/06/2012 01:12 PM, Tim Duly wrote:

> Hi,
>
> I'm a bit new to Mayavi2 so if I am missing an oversight, my apologies.
>   Right now I have successfully loaded in data into the mayavi2 application
> (for now, I am *not* plotting using scripting-- I created the data file
> with help from
> http://github.enthought.com/mayavi/mayavi/auto/example_structured_grid.html#example-structured-grid).
>
>
> There's an issue with scaling of the x-axis.  The coordinates are in
> different units: the y-axis has units of altitude, and the x-axis has units
> of latitude.  To give an example, the y-axis ranges from 90 to 6000 (km),
> while the x-axis only ranges from -30 to 30 (degrees).  Therefore, the
> image is "smashed" together.
>
> I found a way to resolve this in the surface plot: by editing the "actor"
> under the surface module, there's an F0 scale number that I can change
> which essentially stretches out the x-axis.  When I do this, the image
> looks fine.
>
> The issue I have is that this is a bit of a pain.  Let's say I wanted to
> add another module: the grid for example.  I would have to change the F0
> Scale number for this actor too.  And some modules, like the axis labeling
> for example, I can't find how to scale.
>
> So my question is simple: is there some sort of "global" scaling parameter
> that I can set, and that way each module would be appropriately x-scaled?
>   In MATLAB, this is equivalent to the "axis" command: axis([-30 30 90
> 6000]).
>
> I thought I had found my answer here:
> http://github.enthought.com/mayavi/mayavi/mlab.html#changing-the-scale-and-position-of-objects
> ,
> but it's a bit confusing-- how do you do this in the mayavi2 program?
>
> If you'd like the VTK file, feel free to let me know (I don't believe it
> would go through if I attached it).
>
> Thanks,
> Tim
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
> .
>

--
David Ohlemacher
Principle Software Engineer
Scientific Solutions Inc.
99 Perimeter Rd Nashua New Hampshire 03063
603-880-3784

. o .
. . o
o o o

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Scaling x axis globally

Gael Varoquaux
In reply to this post by Tim Duly
On Fri, Apr 06, 2012 at 12:12:48PM -0500, Tim Duly wrote:
> And some modules, like the axis labeling for example, I can't find how
> to scale.

I am not sure that you can.

> So my question is simple: is there some sort of "global" scaling
> parameter that I can set, and that way each module would be
> appropriately x-scaled? In MATLAB, this is equivalent to the "axis"
> command: axis([-30 30 90 6000]).

No, unfortunately there is not. The underlying 3D data visualization
library (VTK) is not meant for this.

> I thought I had found my answer here:
> http://github.enthought.com/mayavi/mayavi/mlab.html#changing-the-scale-and-position-of-objects
> ,
> but it's a bit confusing-- how do you do this in the mayavi2 program?

You do exactly what you did. Sorry :$

Gaƫl
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Scaling x axis globally

Gael Varoquaux
In reply to this post by David Ohlemacher
Thanks, David, for answering! I am quite often not very good at answering
quickly (as you found out earlier), so it's very helpful to have other
people on the list that can share their expertise.

Gael
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Scaling x axis globally

Tim Duly
In reply to this post by David Ohlemacher
David,

Thanks for the information, I'll give this a shot.  I didn't fully
understand what the record feature was used for, but now I do-- situations
exactly like this!  I suppose the majority of Mayavi users start from the
command line, perhaps I should head in that direction too.

Thanks again for the help, I appreciate it.

Tim

On Fri, Apr 6, 2012 at 12:53 PM, David Ohlemacher <[hidden email]>wrote:

> Hi Tim.
>
> I would think you can write a simple script that does the warping you
> require.
>
> In my scripts, I need to scale the z axis.  I do this:
>
> # WarpScalar: Set F2 to a larger value to exagerate elevation features.
> self.plot = self.scene.mlab.surf(self.nDistXs, self.nDistYs, self.nDs,
> colormap='gist_earth', warp_scale=9)
>
> One way to figure out what to do is to use Mayavi's record feature (the
> red circle on the toolbar).  Turn recording on, do what you need to do
> as you are now, and you will see how it would be done from a script from
> the recorder.   I should think it will give you the script you need.
>
> I have not used the Mayavi GUI much, mostly my own scripts that use Mayavi.
>
> Regards,
> David
>
> PS The Geod python module might be helpful.   I use it to convert lats
> and longs to distances so I can plot in meters.
>
>
>
> On 04/06/2012 01:12 PM, Tim Duly wrote:
> > Hi,
> >
> > I'm a bit new to Mayavi2 so if I am missing an oversight, my apologies.
> >   Right now I have successfully loaded in data into the mayavi2
> application
> > (for now, I am *not* plotting using scripting-- I created the data file
> > with help from
> >
> http://github.enthought.com/mayavi/mayavi/auto/example_structured_grid.html#example-structured-grid
> ).
> >
> >
> > There's an issue with scaling of the x-axis.  The coordinates are in
> > different units: the y-axis has units of altitude, and the x-axis has
> units
> > of latitude.  To give an example, the y-axis ranges from 90 to 6000 (km),
> > while the x-axis only ranges from -30 to 30 (degrees).  Therefore, the
> > image is "smashed" together.
> >
> > I found a way to resolve this in the surface plot: by editing the "actor"
> > under the surface module, there's an F0 scale number that I can change
> > which essentially stretches out the x-axis.  When I do this, the image
> > looks fine.
> >
> > The issue I have is that this is a bit of a pain.  Let's say I wanted to
> > add another module: the grid for example.  I would have to change the F0
> > Scale number for this actor too.  And some modules, like the axis
> labeling
> > for example, I can't find how to scale.
> >
> > So my question is simple: is there some sort of "global" scaling
> parameter
> > that I can set, and that way each module would be appropriately x-scaled?
> >   In MATLAB, this is equivalent to the "axis" command: axis([-30 30 90
> > 6000]).
> >
> > I thought I had found my answer here:
> >
> http://github.enthought.com/mayavi/mayavi/mlab.html#changing-the-scale-and-position-of-objects
> > ,
> > but it's a bit confusing-- how do you do this in the mayavi2 program?
> >
> > If you'd like the VTK file, feel free to let me know (I don't believe it
> > would go through if I attached it).
> >
> > Thanks,
> > Tim
> > _______________________________________________
> > Enthought-Dev mailing list
> > [hidden email]
> > https://mail.enthought.com/mailman/listinfo/enthought-dev
> > .
> >
>
> --
> David Ohlemacher
> Principle Software Engineer
> Scientific Solutions Inc.
> 99 Perimeter Rd Nashua New Hampshire 03063
> 603-880-3784
>
> . o .
> . . o
> o o o
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev