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)
Other references:
- a message thread elsewhere saying that this bug maybe is fixed in later versions.
- this page gets a google hit but I don’t understand it or see reference to zticks.
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
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.