本文整理匯總了Python中mpl_toolkits.mplot3d.art3d.pathpatch_2d_to_3d方法的典型用法代碼示例。如果您正苦於以下問題:Python art3d.pathpatch_2d_to_3d方法的具體用法?Python art3d.pathpatch_2d_to_3d怎麽用?Python art3d.pathpatch_2d_to_3d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mpl_toolkits.mplot3d.art3d
的用法示例。
在下文中一共展示了art3d.pathpatch_2d_to_3d方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: text3d
# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import pathpatch_2d_to_3d [as 別名]
def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
'''
Plots the string 's' on the axes 'ax', with position 'xyz', size 'size',
and rotation angle 'angle'. 'zdir' gives the axis which is to be treated
as the third dimension. usetex is a boolean indicating whether the string
should be interpreted as latex or not. Any additional keyword arguments
are passed on to transform_path.
Note: zdir affects the interpretation of xyz.
'''
x, y, z = xyz
if zdir == "y":
xy1, z1 = (x, z), y
elif zdir == "x":
xy1, z1 = (y, z), x
else:
xy1, z1 = (x, y), z
text_path = TextPath((0, 0), s, size=size, usetex=usetex)
trans = Affine2D().rotate(angle).translate(xy1[0], xy1[1])
p1 = PathPatch(trans.transform_path(text_path), **kwargs)
ax.add_patch(p1)
art3d.pathpatch_2d_to_3d(p1, z=z1, zdir=zdir)
示例2: plot_3d_ball_trajectory
# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import pathpatch_2d_to_3d [as 別名]
def plot_3d_ball_trajectory(var, filename, r=0.05):
var = np.asarray(var)
# Normalize directions
var -= var.min(axis=0)
var /= var.max(axis=0)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for x, y, z in var:
p = mpatches.Circle((x, y), r, ec="none")
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=0, zdir="z")
p = mpatches.Circle((x, z), r, ec="none")
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=0, zdir="y")
p = mpatches.Circle((y, z), r, ec="none")
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=0, zdir="x")
# ax.scatter(x, y, z, s=100)
# ax.plot(var[:, 0], var[:, 1], zs=var[:, 2])
ax.view_init(azim=45, elev=30)
ax.set_xlim3d(-0.1, 1.1)
ax.set_ylim3d(-0.1, 1.1)
ax.set_zlim3d(-0.1, 1.1)
plt.savefig(filename, format='png', bbox_inches='tight', dpi=80)
plt.close(fig)
# plt.show()
示例3: my_plot
# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import pathpatch_2d_to_3d [as 別名]
def my_plot(fig, figures_i):
ax = fig.add_subplot(111, projection='3d')
X_i = X[figures_i, :, :]
U_i = U[figures_i, :, :]
K = X_i.shape[1]
ax.set_xlabel('X, east')
ax.set_ylabel('Y, north')
ax.set_zlabel('Z, up')
for k in range(K):
rx, ry, rz = X_i[1:4, k]
qw, qx, qy, qz = X_i[7:11, k]
CBI = np.array([
[1 - 2 * (qy ** 2 + qz ** 2), 2 * (qx * qy + qw * qz), 2 * (qx * qz - qw * qy)],
[2 * (qx * qy - qw * qz), 1 - 2 * (qx ** 2 + qz ** 2), 2 * (qy * qz + qw * qx)],
[2 * (qx * qz + qw * qy), 2 * (qy * qz - qw * qx), 1 - 2 * (qx ** 2 + qy ** 2)]
])
dx, dy, dz = np.dot(np.transpose(CBI), np.array([0., 0., 1.]))
Fx, Fy, Fz = np.dot(np.transpose(CBI), U_i[:, k])
# attitude vector
ax.quiver(rx, ry, rz, dx, dy, dz, length=attitude_scale, arrow_length_ratio=0.0, color='blue')
# thrust vector
ax.quiver(rx, ry, rz, -Fx, -Fy, -Fz, length=thrust_scale, arrow_length_ratio=0.0, color='red')
scale = X_i[3, 0]
ax.auto_scale_xyz([-scale / 2, scale / 2], [-scale / 2, scale / 2], [0, scale])
pad = plt.Circle((0, 0), 20, color='lightgray')
ax.add_patch(pad)
art3d.pathpatch_2d_to_3d(pad)
ax.set_title("Iteration " + str(figures_i))
ax.plot(X_i[1, :], X_i[2, :], X_i[3, :], color='lightgrey')
ax.set_aspect('equal')
示例4: zcircle
# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import pathpatch_2d_to_3d [as 別名]
def zcircle(self, center, r, z0, **kwargs):
circle = mpl.patches.Circle(center, r, **kwargs)
patch = self.add_patch(circle)
art3d.pathpatch_2d_to_3d(patch, z=z0)
#=========================================================================================
# Figure
#=========================================================================================