Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axes3d vs axes3d matplotlib

I just finished a horrible install of scipy, numpy, and matplotlib on OSX Lion. For some reason, I can't do a:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3d

Error output is:

Traceback (most recent call last):
  File "3dPlot.py", line 2, in <module>
    from mpl_toolkits.mplot3d import Axes3d
ImportError: cannot import name Axes3d

but I can do:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d

Is there a different between Axes3d and axes3d, or is my file just named with a lowercase 'a' for some reason?

like image 224
The Wind-Up Bird Avatar asked Jul 17 '12 18:07

The Wind-Up Bird


People also ask

What is Axes3D?

The axes3d is used since it takes a different kind of axis in order to actually graph something in three dimensions. Next: fig = plt. figure() ax1 = fig. add_subplot(111, projection='3d') Here, we define the figure as usual, and then we define the ax1 as a typical subplot, just with a 3d projection this time.

What is axes 3d in python?

An Axes3D object is created just like any other axes using the projection='3d' keyword. Create a new matplotlib.figure.Figure and add a new axes to it of type Axes3D : import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt. figure() ax = fig.


1 Answers

The following two things work for me (watch your capitalization):

from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d import axes3d

But I get the same error for what you wrote (with the d in 3d in lower case). Note that the two imports that do work are not equivalent.

like image 89
JoshAdel Avatar answered Oct 17 '22 15:10

JoshAdel