mercredi 18 mai 2016

Error while plotting an ellipsoid using matplotlib 3D plot with random number of points inside: Python

While plotting an ellipsoid using axes3D, I met with an error

TypeError: unbound method plot() must be called with Axes3D instance as first argument (got ndarray instance instead)

I need to plot the ellipsoid with random number of points inside. SO i used random module. But I couldn't identify the reason for such an error. The program is given below.

import random
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import *
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n=1000000
a= input("Enter the value of semi major axis: \n")
b= input("Enter the value of semi minor axis: \n")
c= input("Enter the value of c \n")
x= random.uniform(-a,a,n)
y= random.uniform(-b,b,n)
z= random.uniform(-c,c,n)
r= (x**2/a**2)+ (y**2/b**2)+ (z**2/c**2)
rd= r[:]<=1
xd=x[rd]
yd=y[rd]
zd=z[rd]
Axes3D.plot3D(xd,yd,zd, "*")
plot.show()

May be there some errors. I am a beginner and please help me.




Aucun commentaire:

Enregistrer un commentaire