4

I am trying to replicate one of the examples in scikit-learn, plot_iris_dataset.py. I believe I have the latest python-matplotlib (as of Feb. 8 2013), but I am getting an error trying to call set_zticks(()) method in Axes3D object. I won't copy all the code, but it's like so:

...
ax = Axes3D(fig, elev=-150, azim=110)
...
ax.set_zticks(()

gives an error:

AttributeError: 'Axes3D' object has no attribute 'set_zticks'

Since I'm new to scikit-learn and matplotlib, I'm not really sure what the call is supposed to do. If I comment it out, I get a 3-D plot just fine (the rest of the code on the above page works). I've tried some googling but haven't found a work-around for this, but am getting hints that maybe this kind of call is outdated. I figured I'd post a question on stackoverflow hoping someone can clarify for me or others.

EDIT: I now notice that the call is supposed to remove the tick marks. It doesn't appear to work for any direction, x, y, or z, but I only get the error for the z-direction. Here's how my graph appears (the data points aren't saving in the PNG file for some reason)My plot, notice the tick marks in all dimensions

Other references:

Steve Koch
  • 912
  • 8
  • 21
  • What does `matplotlib.__version__` give? – tacaswell Feb 09 '13 at 03:04
  • 1
    and you make need to call `plt.draw()` to get the effects of some modifications to `axes` objects to be reflected in the display (you changed the state of the object, but that does not automatically update state of the pretty things based on that object). – tacaswell Feb 09 '13 at 03:08
  • @tcaswell it gives '1.0.1' ... I now see that that's not the latest version. My mistake was that I thought it was up to date since apt-get told me so (I'm still new to linux / etc.). I will try to upgrade to 1.2 and report back. If you see this quickly: what's the best way to upgrade, aside from apt-get? I'll try pip. Thank you! – Steve Koch Feb 09 '13 at 14:58
  • sudo pip install matplotlib --upgrade seems to be working, I'll check whether it fixes things in a bit. – Steve Koch Feb 09 '13 at 14:59
  • No success. It seems likely that this is my problem but I'm having trouble fixing. Even though sudo pip install matplotlib --upgrade worked, I still had version 1.0.1. That's the version I get when using apt-get and installing python-matplotlib. I'm sort of stuck here for now and would appreciate any hints on how to get the latest python-matplotlib. Thank you! – Steve Koch Feb 09 '13 at 15:17
  • you need to make sure that the location where pip installs in higher in the python path (or in the python path) than the system version. If you have more trouble with this open a new question (probably on superuser) about how to get your system configured. – tacaswell Feb 09 '13 at 16:10
  • Thank you, @tcaswell! I'm not sure where this question belongs, so for now I will summarize what worked: – Steve Koch Feb 09 '13 at 19:52
  • In Short: updating matplotlib to latest version 1.2 was the answer. – Steve Koch Feb 09 '13 at 19:53
  • 1
    You should add that last comment as an answer and accept (when it lets you) your own answer. – tacaswell Feb 09 '13 at 20:02

1 Answers1

3

I finally got this problem solved, thanks to @tcaswell ... I am inexperienced, so I'm not quite sure, in the end, what worked, but I will try to explain:

Short answer: Updating to latest matplotlib (to 1.2 from 1.0.1) seemed to be the solution.

Long answer: Updating matplotlib was not easy! I tried a bunch of things, so I'm not sure what ended up working, but here's a general outline:

As of Feb. 9, 2013, apt-get install only gets version 1.0.1. So, I uninstalled and installed from source as described on matplotlib page.

When I tried this, the code compiled but my figure windows would not show up. This was due to a backend problem, not recognizing GTK properly (or something like that). To fix it, I customized the setup.cfg file for building matplotlib

<line 58> gtk = True
<line 57> gtkagg = True
<line 74> backend = GTKAgg

Then I built and compiled as outlined on the above page.

NOTE: I did a WHOLE bunch of other things, so I am not sure if the above is the minimal solution.

Steve Koch
  • 912
  • 8
  • 21
  • http://stackoverflow.com/questions/14803044/matplotlib-animation-moviewriters-fails-on-ubuntu-12-04/14806555#14806555 See this answer for how I deal with this (after the third time I saw the same problem I finally just answered it....) – tacaswell Feb 11 '13 at 05:46