Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

mlab.imshow fails with extent keyword argument #45

Closed
wants to merge 1 commit into from

3 participants

@wecacuee

Replacing module.actor.actor with module.actor. Not sure if this will break other things but this changes allows mlab.imshow(img, extent=[-.1, .1, -.1, .1, 0, 0]) to work which did not work previously. Also the integration test cases run fine.

@wecacuee wecacuee Replacing module.actor.actor with module.actor. Not sure if this will…
… break other things but this changes allows mlab.imshow(img, extent=[-.1, .1, -.1, .1, 0, 0]) to work which did not work previsously.
b2da34c
@wecacuee wecacuee closed this
@GaelVaroquaux
Collaborator

Why did you close this PR?

@wecacuee

I am sorry. I realized that it might not be correct. The documentation of set_extent function says that the function doesn't work with ImageActor.

@GaelVaroquaux
Collaborator
@wecacuee

Yes, it did work for the case of mlab.imshow(img, extent=[....]). But I am afraid that it might break some other cases. I am not sure how many test cases check the use of extent keyword argument though. Moreover, I was trying to use extent keyword argument for a purpose that is better solved by the following snippet of code.

obj = mlab.imshow(img)
obj.actor.orientation = [0, 0, 0] # the required orientation 
obj.actor.position = [0, 0, 0] # the required  position 
obj.actor.scale = [0, 0, 0] # the required scale
@alimuldal

It seems to me that orientation, position and scale should ideally be arguments to imshow. At the very least, the extent argument should be removed from the documentation for imshow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2012
  1. @wecacuee

    Replacing module.actor.actor with module.actor. Not sure if this will…

    wecacuee authored
    … break other things but this changes allows mlab.imshow(img, extent=[-.1, .1, -.1, .1, 0, 0]) to work which did not work previsously.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 7 deletions.
  1. +7 −7 mayavi/tools/tools.py
View
14 mayavi/tools/tools.py
@@ -291,12 +291,12 @@ def set_extent(module, extents):
extenty = 0.5*(ymax - ymin)
extentz = 0.5*(zmax - zmin)
# Now the actual bounds.
- xmin, xmax, ymin, ymax, zmin, zmax = module.actor.actor.bounds
+ xmin, xmax, ymin, ymax, zmin, zmax = module.actor.bounds
# Scale the object
boundsx = 0.5*(xmax - xmin)
boundsy = 0.5*(ymax - ymin)
boundsz = 0.5*(zmax - zmin)
- xs, ys, zs = module.actor.actor.scale
+ xs, ys, zs = module.actor.scale
if not numpy.allclose(xmin, xmax):
scalex = xs*extentx/boundsx
else:
@@ -310,16 +310,16 @@ def set_extent(module, extents):
else:
scalez = 1
- module.actor.actor.scale = (scalex, scaley, scalez)
+ module.actor.scale = (scalex, scaley, scalez)
## Remeasure the bounds
- xmin, xmax, ymin, ymax, zmin, zmax = module.actor.actor.bounds
+ xmin, xmax, ymin, ymax, zmin, zmax = module.actor.bounds
xcenter = 0.5*(xmax + xmin)
ycenter = 0.5*(ymax + ymin)
zcenter = 0.5*(zmax + zmin)
# Center the object
- module.actor.actor.origin = (0., 0., 0.)
- xpos, ypos, zpos = module.actor.actor.position
- module.actor.actor.position = (xpos + xo -xcenter, ypos + yo - ycenter,
+ module.actor.origin = (0., 0., 0.)
+ xpos, ypos, zpos = module.actor.position
+ module.actor.position = (xpos + xo -xcenter, ypos + yo - ycenter,
zpos + zo -zcenter)
Something went wrong with that request. Please try again.