Re: [MayaVi-users] Setting the aspect ratio (x/y/z) of a surface plot?
Status: Beta
Brought to you by:
prabhu_r
|
From: Fernando P. <fp...@pi...> - 2003-02-18 21:03:32
|
On Wed, 19 Feb 2003, Prabhu Ramachandran wrote:
> >>>>> "FP" == Fernando Perez <fp...@pi...> writes:
>
> FP> Hi all, sorry if this has been already answered, I googled
> FP> around and couldn't find a solution. I am plottinng arrays
> FP> using mayavi (and Prabhu's soon-to-be-released mayamat module)
> FP> but I have a little problem. The ranges of the x,y and z data
> FP> are numerically wildly different, so I end up with one
> FP> direction either much larger or much smaller than the others.
>
> FP> I was wondering if there is a way to set the aspect ratio
> FP> manually. It would be great if one could just set a ratio for
> FP> x:y:z irrespective of the numerical ranges.
>
> Well, there are a couple of kludges:
>
> 1. If you are using mayamat.py I can arrange for a scale argument
> which will scale the data appropriately internally (easy to do --
> just change the arange appropriately).
That would be good. Here are some thoughts on my 'ideal' interface for this.
Take from this what you want/like.
Since the whole point of visualization is seeing as much information as
possible, I would argue for a 'scale' parameter which defaults to 'auto'. In
this case, surf/view would automatically compute the necessary x/y/z scaling
to make the plot be visually balanced. Something like a 1:1:0.7 scale (x:y:z)
might be a nice visual choice. Here I mean the _final_ aspect ratio would be
1:1:0.7, which would of course require the computation of the necessary
scaling factors to obtain this visual result. The labels on the axes would
serve the purpose of indicating the actual ranges.
Users could also supply a 3-element list or tuple to the 'scale' argument,
which would then be used to manually set the scaling. A convenient shortcut
would be to be able to pass a single number to scale when it's meant to be
used for all three values.
here's some pseudo-code:
def view(... ,scale='auto'):
...
if scale=='auto':
scale = compute_auto_scaling()
else:
try:
len(scale)
except TypeError:
scale = (scale,scale,scale)
set_scales(scale)
...
One can then call 'scale=1' to set scaling to the current behavior,
'scale=(1,1,2)' to set the z axis expanded by a factor of 2, or leave 'auto'
to enjoy Mayavi's auto-scaling capabilities (yet to be written :)
This seems (to me) to strike a good balance between usability for the most
common cases and flexibility. In science, most plots show quantities whose
magnitudes differ vastly (often by orders of magnitude, because of the units
chosen). We are all used to reading the labels on the axes to figure out what
the actual ranges are, instead of relying on plots which are a kilometer long
by a millimeter tall :)
>
> 2. From within MayaVi you can do this by visiting the pipeline
> browser for an actor, clicking on the actor and then changing the
> scale in the correct entry.
> SurfaceMap(Dclick)->ShowPipeline(click)->Actor(dclick)->scale(edit).
Well, this doesn't quite work. The outline also needs to be scaled, and so do
the axes. I could do the outline, but the axes didn't have such a
parameter. So I just had to delete the axes module altogether.
Thanks for all this, mayavi keeps getting better.
Cheers,
Fernando
|