exceptions in 3d zoom operation (bug report)

Fairly easy to demonstrate; run the code below, and press the right mouse button in the middle of the box somewhere,

and rapidly zoom in/out. It might take a few seconds, but I end up with an exception on both Windows and OSX. If it doesn’t

give you an exception within a few seconds, let go of the right mouse button, and zoom more. I just push the mouse to and fro

a few times, and it does it for me.

File “C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\axis3d.py”, line 233, in draw

newval = get_flip_min_max(xyz1[0], newindex, mins, maxs)

IndexError: list index out of range

I’m working on trying to fix, but I don’t know enough about the code to be confident that what I do won’t break something else.

--------------------------- cut ------------------------------------

from mpl_toolkits.mplot3d import Axes3D

from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.gca(projection=‘3d’)

plt.show()

···


Daniel Hyams
dhyams@…287…

Fix (and it looks like this would need to be fixed in 1.0.1 as well):

A few lines up in draw() (line 183 in axis3d.py) there is a filter for throwing out grid lines that are outside the axis limits. In

exceptional cases though, “interval” has a greater number listed first, then the smaller. That in and of itself might warrant

further investigation, but simply replacing:

majorLocs = [loc for loc in majorLocs if \

interval[0] <= loc <= interval[1]]

with:

if interval[0] > interval[1]: interval[1],interval[0] = interval[0],interval[1]

majorLocs = [loc for loc in majorLocs if \

interval[0] <= loc <= interval[1]]

seems to solve the problem at hand.

···

On Sun, Jan 9, 2011 at 4:55 PM, Daniel Hyams <dhyams@…287…> wrote:

Fairly easy to demonstrate; run the code below, and press the right mouse button in the middle of the box somewhere,
and rapidly zoom in/out. It might take a few seconds, but I end up with an exception on both Windows and OSX. If it doesn’t

give you an exception within a few seconds, let go of the right mouse button, and zoom more. I just push the mouse to and fro

a few times, and it does it for me.

File “C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\axis3d.py”, line 233, in draw

newval = get_flip_min_max(xyz1[0], newindex, mins, maxs)

IndexError: list index out of range

I’m working on trying to fix, but I don’t know enough about the code to be confident that what I do won’t break something else.

--------------------------- cut ------------------------------------

from mpl_toolkits.mplot3d import Axes3D

from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.gca(projection=‘3d’)

plt.show()


Daniel Hyams
dhyams@…287…


Daniel Hyams
dhyams@…287…

Technically speaking, axes3d zoom feature is very experimental (and temperamental as you have discovered). In particular, I have noticed issues for having multiple subplots, parts of the zoomed in figure will show up on the neighboring subplots.

What would probably be the best way to “fix” this problem would be to re-implement zooming so that it simply changes the limits of the displayed 3d domain. I currently do not like how zooming also zooms the entire display (thereby losing sight of the axes labels and such). This approach would fix that issue as well.

Ben Root

···

On Sun, Jan 9, 2011 at 3:55 PM, Daniel Hyams <dhyams@…287…> wrote:

Fairly easy to demonstrate; run the code below, and press the right mouse button in the middle of the box somewhere,
and rapidly zoom in/out. It might take a few seconds, but I end up with an exception on both Windows and OSX. If it doesn’t

give you an exception within a few seconds, let go of the right mouse button, and zoom more. I just push the mouse to and fro

a few times, and it does it for me.

File “C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\axis3d.py”, line 233, in draw

newval = get_flip_min_max(xyz1[0], newindex, mins, maxs)

IndexError: list index out of range

I’m working on trying to fix, but I don’t know enough about the code to be confident that what I do won’t break something else.

--------------------------- cut ------------------------------------

from mpl_toolkits.mplot3d import Axes3D

from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.gca(projection=‘3d’)

plt.show()


Daniel Hyams
dhyams@…287…

Hmm, I would rather investigate the cause of this instead. Also, messing around with the contents of the interval array might have implications elsewhere. As I noted in my previous email, there are still other problems with mplot3d zooming that I would hardly call it “fiixed” at this point.

Good catch though, and it gives me a good starting place to examine this further.

Ben Root

···

On Sun, Jan 9, 2011 at 4:15 PM, Daniel Hyams <dhyams@…287…> wrote:

Fix (and it looks like this would need to be fixed in 1.0.1 as well):

A few lines up in draw() (line 183 in axis3d.py) there is a filter for throwing out grid lines that are outside the axis limits. In

exceptional cases though, “interval” has a greater number listed first, then the smaller. That in and of itself might warrant

further investigation, but simply replacing:

majorLocs = [loc for loc in majorLocs if \

interval[0] <= loc <= interval[1]]

with:

if interval[0] > interval[1]: interval[1],interval[0] = interval[0],interval[1]

majorLocs = [loc for loc in majorLocs if \

interval[0] <= loc <= interval[1]]

seems to solve the problem at hand.

Agreed; this is a band-aid at best.

···

On Sun, Jan 9, 2011 at 5:23 PM, Benjamin Root <ben.root@…1304…> wrote:

On Sun, Jan 9, 2011 at 4:15 PM, Daniel Hyams <dhyams@…287…> wrote:

Fix (and it looks like this would need to be fixed in 1.0.1 as well):

A few lines up in draw() (line 183 in axis3d.py) there is a filter for throwing out grid lines that are outside the axis limits. In

exceptional cases though, “interval” has a greater number listed first, then the smaller. That in and of itself might warrant

further investigation, but simply replacing:

majorLocs = [loc for loc in majorLocs if \

interval[0] <= loc <= interval[1]]

with:

if interval[0] > interval[1]: interval[1],interval[0] = interval[0],interval[1]

majorLocs = [loc for loc in majorLocs if \

interval[0] <= loc <= interval[1]]

seems to solve the problem at hand.

Hmm, I would rather investigate the cause of this instead. Also, messing around with the contents of the interval array might have implications elsewhere. As I noted in my previous email, there are still other problems with mplot3d zooming that I would hardly call it “fiixed” at this point.

Good catch though, and it gives me a good starting place to examine this further.

Ben Root


Daniel Hyams
dhyams@…287…