本文整理汇总了Python中mpl_toolkits.mplot3d.Axes3D.plot方法的典型用法代码示例。如果您正苦于以下问题:Python Axes3D.plot方法的具体用法?Python Axes3D.plot怎么用?Python Axes3D.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.mplot3d.Axes3D
的用法示例。
在下文中一共展示了Axes3D.plot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeequator
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def makeequator( ax ) :
npts = 256
x = numpy.zeros( npts )
y = numpy.zeros( npts )
z = numpy.zeros( npts )
n = 0
for phi in numpy.arange( 0., 2*math.pi, 2*math.pi/npts ) :
x[n] = math.cos(phi)
y[n] = math.sin(phi)
n = n+1
q = Axes3D.plot(ax, x, y, zs=z, c='gray' )
q = Axes3D.plot(ax, x, z, zs=y, c='gray' )
q = Axes3D.plot(ax, z, y, zs=x, c='gray' )
示例2: visualize
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def visualize( Z, solution=[]):
Y = np.arange(0,YSIZE,1)
X = np.arange(0,XSIZE,1)
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y = np.meshgrid(X, Y)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)
if 0 < len( solution) :
# TODO plot line not implemented - which function again?
Axes3D.plot(X, Y, solution)
ax.set_zlim(0.0, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
示例3: drawcylinder
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def drawcylinder( ax ) :
npts = 2048
xa = numpy.array( [-1, 1] )
ya = numpy.array( [0.,0.] )
za = numpy.array( [40.,40.] )
q = Axes3D.plot(ax, xa, za, zs=ya, c='gray' )
q = Axes3D.plot(ax, ya, za, zs=xa, c='gray' )
za = numpy.array( [-40.,-40.] )
q = Axes3D.plot(ax, xa, za, zs=ya, c='gray' )
q = Axes3D.plot(ax, ya, za, zs=xa, c='gray' )
xa = numpy.array( [0.,0.] )
za = numpy.array( [0.,0.] )
ya = numpy.array( [-40.,40.] )
q = Axes3D.plot(ax, xa, ya, zs=za, c='gray', linestyle='--' )
x = numpy.zeros( npts )
y = -30.*numpy.ones( npts )
z = numpy.zeros( npts )
xx = numpy.zeros( npts )
yy = numpy.zeros( npts )
zz = numpy.zeros( npts )
n = 0
for phi in numpy.arange( 0., 2*math.pi, 2*math.pi/npts ) :
x[n] = math.cos(phi)
z[n] = math.sin(phi)
n = n+1
#q = Axes3D.plot(ax, x, y, zs=z, c='gray' )
y = 30.* numpy.ones( npts )
#q = Axes3D.plot(ax, x, y, zs=z, c='gray' )
n = 0
for phi in numpy.arange( -30., 30.0, (60./npts) ) :
yy[n] = phi
amp = math.cos(phi)
zz[n] = amp * math.cos( .007 * (30.-phi) )
xx[n] = -1.* amp * math.sin( .007 * (30.-phi) )
#zz[n] = math.cos(phi)
n = n+1
q = Axes3D.plot(ax, xx, yy, zs=zz, c='black' )
xxx = numpy.zeros( 2 )
yyy = 40.*numpy.ones( 2 )
zzz = numpy.zeros( 2 )
zzz[0] = -1.
zzz[1] = 1.
q = Axes3D.plot(ax, xxx, yyy, zs=zzz, c='black' )
xxxx = numpy.zeros( 2 )
yyyy = -40.*numpy.ones( 2 )
zzzz = numpy.zeros( 2 )
xxxx[0] = -1.* math.sin( .007 * (60.) )
zzzz[0] = math.cos( .007 * (60.) )
xxxx[1] = 1.* math.sin( .007 * (60.) )
zzzz[1] = -1.* math.cos( .007 * (60.) )
q = Axes3D.plot(ax, xxxx, yyyy, zs=zzzz, c='black' )
示例4: addcurve
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def addcurve( ax, path, endpoints, color ) :
px = path[ :,0 ]
py = path[ :,1 ]
pz = path[ :,2 ]
n = len(px) - 1
q = Axes3D.plot(ax, px, py, zs=pz, c=color, linewidth=2 )
px = endpoints[ :,0 ]
py = endpoints[ :,1 ]
pz = endpoints[ :,2 ]
print px, py, pz
q = Axes3D.scatter(ax, px,py, zs=pz, c=color, marker='o', s=60)
示例5: vectorplot
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def vectorplot(Points_From,Points_To):
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.patches import FancyArrowPatch
from mpl_toolkits.mplot3d import proj3d
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for i in range(len(Points_From)):
# ax.plot([Points_From[i][0], Points_To[i][0]], [Points_From[i][1], Points_To[i][1]],zs=[Points_From[i][2], Points_To[i][2]])
a=Arrow3D([Points_From[i][0], Points_To[i][0]], [Points_From[i][1], Points_To[i][1]],[Points_From[i][2], Points_To[i][2]],mutation_scale=2000, lw=3, arrowstyle="-|>", color="r")
ax.add_artist(a)
plt.show()
Axes3D.plot()
示例6: end_effector
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
stuff = end_effector(dh_mat)
A06 = stuff[0]
end_of_links = stuff[1]
X = np.array([ np.array(val[0])[0][0] for val in end_of_links])
Y = np.array([ np.array(val[1])[0][0] for val in end_of_links])
Z = np.array([ np.array(val[2])[0][0] for val in end_of_links])
print "The position of the End Effector is"
print A06[:,3][:3]
print "The orientation of the End Effector is"
print A06[:3,:3]
# make graph
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(X,Y,Z)
plt.show()
Axes3D.plot()
ax.savefig('plot1.png')
'''
Answer
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The position of the End Effector is
[[ 0.39269908]
[ 1.09980586]
[ 0.55536037]]
The orientation of the End Effector is
[[ -5.00000000e-01 -5.00000000e-01 7.07106781e-01]
[ 5.00000000e-01 5.00000000e-01 7.07106781e-01]
[ -7.07106781e-01 7.07106781e-01 2.22044605e-16]]
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
示例7: dynamics
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def dynamics():
# Number of particles
N=2
# Total time
T =10.0
# Steps
steps =1000.0
# Time step
dt =T/steps
# Variance: The Weiner Process states that the variance is t.
variance =1
# MAKE THE FORCE VECTORS
# allForces will be a list containing 3Nx1 force vectors
# The 3Nx1 vectors are the 3 dimensional force vectors for each N particles.
allForces =[]
for timestep in range(0, int(steps)):
allForces.append(norm.rvs(loc =0,size =3*N, scale = variance))
# MAKE THE POSITION VECTORS
# Make the Position vector for all N particles
position =[[1,0,0,2,0,0]] # MAKE NXN POSITION VECTOR
for timestep in range(0,int(steps)):
# Make the mobility matrix of p1
mobility = mobilityMatrix(position[timestep], N)
# Append the next position to the path
position.append(position[timestep] + MF(mobility,allForces[timestep]))
# MAKE LISTS FOR THE X PATHS, Y PATHS, AND Z PATHS SO WE CAN PLOT THE PARTICLES
allxPaths,allyPaths,allzPaths =[[],[]],[[],[]],[[],[]] # A list for each particles # MAKE EACH LIST N LENGTH
for particle in range(0,2):
for vector in position:
allxPaths[particle].append(vector[3*particle])
allyPaths[particle].append(vector[3*particle+1])
allzPaths[particle].append(vector[3*particle+2])
# MAKE A SCATTER PLOT FOR THE PATHS OF THE PARTICLES
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for particle in range(0,N):
ax.plot(allxPaths[particle],allyPaths[particle],allzPaths[particle], alpha =.3,) # plots the paths of the particle
ax.scatter(-1,0,0, color ='green', marker ='H',s =50, label ='start') # labels the starting points
ax.scatter(1,0,0, color ='blue', marker ='H',s =50, label ='start')
ax.scatter(allxPaths[0][-1],allyPaths[0][-1],allzPaths[0][-1], color ='blue', marker ='^',s =50, label ='end') #label the end points
ax.scatter(allxPaths[1][-1],allyPaths[1][-1],allzPaths[1][-1], color ='green', marker ='^',s =50, label ='end') #label the end points
ax.text2D(0.05, 0.95, "3D Brownian Motion of two particles", transform=ax.transAxes) # Makes a 2D title
ax.set_xlabel('X Position')
ax.set_ylabel('Y Position')
ax.set_zlabel('Z Position')
plt.show()
plt.legend(numpoints =1)
Axes3D.plot()
return 0
示例8: brownian
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def brownian():
# CALCULATE THE BROWNIAN MOTION OF A PARTICLE IN 3D
# Number of particles
N =1
# Initial value
x=0
y=0
z=0
# Total time
T =10.0
# Steps
steps =10000.0
# Time step
dt =T/steps
# Variance: The Weiner Process states that the variance is t.
variance =dt
# Create a list of all of the times
time =np.arange(0,T,dt)
# Create random variables from a gaussian distribution in a list
# xGaussian and yGaussian are lists containing N lists of some number(steps) of random variables
# Together they are the change in the position of the particle (the delta-x vector)
xGaussian =[]
yGaussian =[]
zGaussian =[]
for particle in range(0,N):
xGaussian.append(norm.rvs(loc =0,size =steps, scale = variance))
yGaussian.append(norm.rvs(loc =0,size =steps, scale = variance))
zGaussian.append(norm.rvs(loc =0,size =steps, scale = variance))
# allxPaths contains the xPaths of the all N particles. xPath contains the path of a particle in the x direction.
allxPaths, allyPaths, allzPaths =[], [], []
xPath, yPath, zPath=[0], [0], [0]
for particle in range(0,N):
for t in range(0,int(steps)):
x += xGaussian[particle][t]
y += yGaussian[particle][t]
z += zGaussian[particle][t]
xPath.append(x)
yPath.append(y)
zPath.append(z)
allxPaths.append(xPath)
allyPaths.append(yPath)
allzPaths.append(zPath)
#reset the path, so every path is unique
x, y, z =0, 0, 0
xPath, yPath, zPath =[0], [0], [0]
# MAKE A SCATTER PLOT FOR THE PATHS OF THE PARTICLES
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for particle in range(0,N):
ax.plot(allxPaths[particle],allyPaths[particle],allzPaths[particle], alpha =.3) # plots the paths of the particle
ax.scatter(0,0,0, color ='green', marker ='H',s =50, label ='start') # labels the starting point
ax.scatter(allxPaths[-1][-1],allyPaths[-1][-1],allzPaths[-1][-1], color ='red', marker ='H',s =50, label ='end')
ax.text2D(0.05, 0.95, "3D Brownian Motion", transform=ax.transAxes) # Makes a 2D title
ax.set_xlabel('X Position')
ax.set_ylabel('Y Position')
ax.set_zlabel('Z Position')
plt.show()
plt.legend(numpoints =1)
Axes3D.plot()
return 0
示例9: makeaxes
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot [as 别名]
def makeaxes( ax ) :
x = numpy.array( [-1, 1] )
y = numpy.array( [0,0] )
q = Axes3D.plot(ax, x, y, zs=y, c='black' )
q = Axes3D.plot(ax, y, x, zs=y, c='black' )
q = Axes3D.plot(ax, y, y, zs=x, c='black' )