Reputation: 1331
I am a new in numpy and I try to practice the basic operations. Here is a code to plot a 2D gaussian distribution. I have an error in matplotlib. How can I fix that?
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
X,Y=np.meshgrid(np.linspace(-1,1,10),np.linspace(-1,1,10));
mu,sigma=0,1; #suppose that mux=muy=mu=0 and sigmax=sigmay=sigma
G=np.exp(-((X-mu)**2+(Y-mu)**2)/2.0*sigma**2)
print G
fig=plt.figure();
ax=fig.add_subplot(111,projection='3d')
surf=ax.plot_surface(X,Y,G,c='red')
plt.show()
I have this error
File "/Library/Python/2.7/site-packages/mpl_toolkits/mplot3d/__init__.py", line 4, in
from matplotlib.externals import six
ImportError: No module named externals
Upvotes: 1
Views: 6208
Reputation: 152587
Because with my versions it works so I suspect you need to upgrade mpl_toolkits
(and/or matplotlib
).
It seems like matplotlib
dropped support for older Python versions (and you have a more recent version) and therefore doesn't need an externals
submodule anymore. But you didn't update mpl_toolkits
which still thinks matplotlib has this submodule. And therefore you get this Error.
Upvotes: 2