loss of 3d plot interactivity after cla()?

Hi all,

I'm (finally) getting started with matplotlib, and am enjoying the lovely plot quality. However, as a non-matlab user, I'm finding it *extremely* difficult to figure out how to do even the simplest tasks / understand the code samples. (e.g. what is the '111' in the boilerplate calls to add_subplot() in the various examples? I couldn't find anything in the docs, and had to resort to the matlab documentation!)

Anyhow, I've soldiered on, and have run across an issue that I don't know if is related to my non-comprehension of the right syntax, a bug in the Axes3D code, or a problem with the MacOSX backend. Here's code to duplicate the issue (Python 2.7, OS X 10.7, matplotlib 1.1.0, via pre-built installer):

import matplotlib as mpl
mpl.use('macosx')
import matplotlib.pyplot as plt
plt.ion()
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot([1,2,3], [2,3,2], [2,5,7]) # draws immediately!?
ax.cla() # plt.cla() has same effect
ax.plot([1,2,3], [2,3,2], [2,5,7]) # doesn't draw?
plt.draw() # now draws, but z-order is messed up -- grid lines on top?
# And worse, now figure can't be interactively rotated with the mouse

Nothing can restore interactivity short of making a new figure, or calling fig.clf() (which I *randomly* happened on), and then making a new set of axes.

Is this a known issue? Am I doing something wrong -- is ax.cla() or plt.cla() the wrong thing to clear the figure?

Thanks a lot,
Zach

For posterity, Ben Root let me know off-list that the interaction bug is fixed in the soon-to-be-released v 1.1.1.

Also, regarding documentation, I mentioned to Ben and I'll mention here too that I'd be happy to help out where I can with what sort of information would be helpful for getting people in my position (tons of python knowledge, but almost none of matlab) up and running with matplotlib -- which as of now seems to rely on similarity-with-matlab for getting new users started.

I'm obviously not the right person to write new docs, but if there's any other way I can help, I'd be happy to.

Zach

···

On Mar 16, 2012, at 5:34 PM, Zachary Pincus wrote:

Hi all,

I'm (finally) getting started with matplotlib, and am enjoying the lovely plot quality. However, as a non-matlab user, I'm finding it *extremely* difficult to figure out how to do even the simplest tasks / understand the code samples. (e.g. what is the '111' in the boilerplate calls to add_subplot() in the various examples? I couldn't find anything in the docs, and had to resort to the matlab documentation!)

Anyhow, I've soldiered on, and have run across an issue that I don't know if is related to my non-comprehension of the right syntax, a bug in the Axes3D code, or a problem with the MacOSX backend. Here's code to duplicate the issue (Python 2.7, OS X 10.7, matplotlib 1.1.0, via pre-built installer):

import matplotlib as mpl
mpl.use('macosx')
import matplotlib.pyplot as plt
plt.ion()
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot([1,2,3], [2,3,2], [2,5,7]) # draws immediately!?
ax.cla() # plt.cla() has same effect
ax.plot([1,2,3], [2,3,2], [2,5,7]) # doesn't draw?
plt.draw() # now draws, but z-order is messed up -- grid lines on top?
# And worse, now figure can't be interactively rotated with the mouse

Nothing can restore interactivity short of making a new figure, or calling fig.clf() (which I *randomly* happened on), and then making a new set of axes.

Is this a known issue? Am I doing something wrong -- is ax.cla() or plt.cla() the wrong thing to clear the figure?

Thanks a lot,
Zach
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi all,

I’m (finally) getting started with matplotlib, and am enjoying the lovely plot quality. However, as

Finally getting started? You were one of our first contributors!

http://sourceforge.net/mailarchive/message.php?msg_id=5192900

a non-matlab user, I’m finding it extremely difficult to figure out how to do even the simplest tasks / understand the code samples. (e.g. what is the ‘111’ in the boilerplate calls to add_subplot() in the various examples? I couldn’t find anything in the docs, and had to resort to the matlab documentation!)

The 111, and the numbering scheme in general, is covered in the pyplot tutorial

http://matplotlib.sourceforge.net/users/pyplot_tutorial.html#working-with-multiple-figures-and-axes

and in the subplots API docs

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.subplot

but it looks like the Figure.add_subplot docs could use some improvement here to explain the numbering scheme better (as pyplot.subplot does)

http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_subplot

I’ll try and find some time today to clean up this docstring and to improve the pyplot tutorial to use the recommended “subplots” command.

JDH

···

On Fri, Mar 16, 2012 at 4:34 PM, Zachary Pincus <zachary.pincus@…1927…> wrote:

I'm (finally) getting started with matplotlib, and am enjoying the lovely plot quality. However, as

Finally getting started? You were one of our first contributors!
[matplotlib-devel] Bugs and patches posted | matplotlib

Heh. Well, now I'm actively trying to use it as a plotting library rather than a great place to snag code from for my own projects :slight_smile:

The 111, and the numbering scheme in general, is covered in the pyplot tutorial

http://matplotlib.sourceforge.net/users/pyplot_tutorial.html#working-with-multiple-figures-and-axes

and in the subplots API docs

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.subplot

but it looks like the Figure.add_subplot docs could use some improvement here to explain the numbering scheme better (as pyplot.subplot does)

http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_subplot

Aah, thanks for the pointers! I realize that it's hard to keep all the docs spiffy when there are a couple of different ways to get the various bits of functionality. I'll go more thoroughly through the pyplot tutorial...

Thanks again,
Zach