本文整理汇总了Python中mpl_toolkits.mplot3d.art3d.pathpatch_2d_to_3d函数的典型用法代码示例。如果您正苦于以下问题:Python pathpatch_2d_to_3d函数的具体用法?Python pathpatch_2d_to_3d怎么用?Python pathpatch_2d_to_3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pathpatch_2d_to_3d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: photogeneration
def photogeneration(loc):
arl = 0.10
sep = 0.05
arprop = dict(mutation_scale=10,
lw=1, arrowstyle="-|>",
zorder=20)
x, y, z = loc
#electron
electron, = ax.plot3D([x-sep/2], [y], [z],
c='c', marker='$-$', markersize=7, ls='none')
v = ((x-sep/2,x-sep/2), (y,y), (z+0.02, z+arl))
ar = Arrow3D(*v, color='c', **arprop)
ax.add_artist(ar)
#hole
hole, = ax.plot3D([x+sep/2], [y], [z],
c='r', marker='$+$', markersize=7, ls='none')
v = ((x+sep/2,x+sep/2), (y,y), (z-0.02, z-arl))
ar = Arrow3D(*v, color='r', **arprop)
ax.add_artist(ar)
#photon
draw_photon(ax, (0,0,1), location=(x,y,z-0.35), length=0.3, amplitude=0.02)
#encircle
ell = Ellipse((x,y), 2.5*sep, 2.5*sep, ls=':', ec='y', fc='none', lw=1)
art3d.pathpatch_2d_to_3d(ell, z, 'z')
ell._path2d = ell._path
ax.add_patch(ell)
return electron, hole
开发者ID:apodemus,项目名称:thesis,代码行数:32,代码来源:CCD.arch.py
示例2: plot_track
def plot_track(track_obj, dim):
fig = plt.figure()
if dim == '2d':
ax = plt.plot(track_obj.x, track_obj.y)
elif dim == '3d':
#ax = fig.gca(projection = '3d')
#ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)
#Draw Runway
rwy = Rectangle((-1250.529, 1166.953), 3021.95, 61, angle=-3, color='grey') #angle=350.12 angle=-9.88
ax.add_patch(rwy)
art3d.pathpatch_2d_to_3d(rwy, z=0,zdir="z")
ax.plot(track_obj.x, track_obj.y, zs = track_obj.z)
elif dim == '3da':
ax = fig.gca(projection = '3d')
u = 1; v = 1; w = 1;
ax.quiver(track_obj.x, track_obj.y, track_obj.z, u, v, w, length = 100) #self.s)
ax.set_aspect('equal')
ax.set_xlim(-2000,20000)
ax.set_ylim(-3000,5000)
ax.set_zlim(0,1500)
plt.show()
开发者ID:divensje,项目名称:HMMH_Tools,代码行数:25,代码来源:visualization.py
示例3: make_path_plot_3d
def make_path_plot_3d():
fig1 = plt.figure()
ax = fig1.gca(projection='3d')
for i in os.listdir(obstacleFolder):
obstaclePath = obstacleFolder + i
ob = np.loadtxt(obstaclePath)
ob = np.vstack((ob, ob[0, :]))
CH = Delaunay(ob).convex_hull
x,y,z = ob[:,0],ob[:,1],ob[:,2]
S = ax.plot_trisurf(x,y,z,triangles=CH,shade=True,cmap=cm.copper,lw=0.2)
txt = np.loadtxt(rrtPath)
start = txt[0,0:2]
goal = txt[-1,0:2]
startCircle = Circle(start,2,color='g')
goalCircle = Circle(goal,2,color='r')
ax.add_patch(startCircle)
ax.add_patch(goalCircle)
art3d.pathpatch_2d_to_3d(startCircle,z=txt[0,2],zdir='y')
art3d.pathpatch_2d_to_3d(goalCircle,z=txt[-1,2],zdir='y')
plt.plot(txt[:, 0], txt[:, 1], txt[:,2], 'bo-', markersize=10, linewidth=3)
开发者ID:wallarelvo,项目名称:flatland,代码行数:26,代码来源:plot_path.py
示例4: pitches_by_type
def pitches_by_type(self, pitcher, pitch_type=None):
pitch_types = self.db.get_pitch_types(pitcher_id=pitcher.pid)
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
pitch_count = 0
sz_bot = self.db.get_average_for_pitches(entities.Pitch.sz_bot, pitcher.pid, pitch_type)[0]
sz_top = self.db.get_average_for_pitches(entities.Pitch.sz_top, pitcher.pid, pitch_type)[0]
for t in pitch_types:
if pitch_type is not None and not t[0] == pitch_type:
LOG.info("Type [%s] does not match selected type [%s]", t[0], pitch_type)
continue
pitches = self.db.get_pitches(
pitcher_id=pitcher.pid, pitch_type=t[0])
lines = []
for pitch in pitches:
if pitch.x0 is None or \
pitch.y0 is None or \
pitch.z0 is None or \
pitch.px is None or \
pitch.pz is None or \
pitch.vx0 is None or \
pitch.vy0 is None or \
pitch.vz0 is None or \
pitch.ax is None or \
pitch.ay is None or \
pitch.az is None:
continue
t_to_catcher = (- pitch.vy0 - math.sqrt((pitch.vy0**2)-2*pitch.ay*(pitch.y0-0))) / pitch.ay
pitch_line = [(pitch.x0 + pitch.vx0 * t + pitch.ax * t**2 / 2,
pitch.y0 + pitch.vy0 * t + pitch.ay * t**2 / 2,
pitch.z0 + pitch.vz0 * t + pitch.az * t**2 / 2)
for t in numpy.linspace(0, t_to_catcher)]
lines.append(pitch_line)
ax.add_collection(Line3DCollection(lines, label=t[0], linewidths=1, alpha=0.5, colors=next(ax._get_lines.prop_cycler)['color']))
pitch_count += len(pitches)
strikezone = patches.Rectangle((-0.7083, sz_bot), 0.7083 * 2, sz_top - sz_bot, fill=False, label="Strikezone")
ax.add_patch(strikezone)
art3d.pathpatch_2d_to_3d(strikezone, z=1.417, zdir="y")
ax.set_xlim(-0.7083 * 4, 0.7083 * 4)
ax.set_ylim(0, 50)
ax.set_zlim(-1, sz_top * 2)
ax.set_title("Pitch Location by type for " + str(pitcher))
ax.legend()
LOG.info("Evaluated [%i] pitches", pitch_count)
plt.show(block=True)
开发者ID:alnkpa,项目名称:fillbass,代码行数:54,代码来源:parsedata.py
示例5: scatter_plot
def scatter_plot(self, equators=True, tagging=True, depth_cap=None):
if depth_cap is None:
depth_cap = self.height
fig = plt.figure(figsize=(12, 10))
ax = fig.add_subplot(111, projection="3d")
plt.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
xs = [self.nodes[self.root].coord.x]
ys = [self.nodes[self.root].coord.y]
zs = [self.nodes[self.root].coord.z]
plot_color_board = ["blue", "red", "yellow", "green", "black"]
font0 = FontProperties()
font0.set_size(8)
current_generation = deque([self.root])
next_generation = True
while next_generation:
next_generation = deque()
while current_generation:
n = current_generation.popleft()
if self.nodes[n].depth <= depth_cap:
xs.append(self.nodes[n].coord.x)
ys.append(self.nodes[n].coord.y)
zs.append(self.nodes[n].coord.z)
if tagging:
ax.text(self.nodes[n].coord.x + 0.01,
self.nodes[n].coord.y + 0.01,
self.nodes[n].coord.z + 0.01,
("n{0}".format(n)), fontproperties=font0)
for child in self.nodes[n].children:
next_generation.append(child)
if self.nodes[n].depth <= depth_cap:
xe = [self.nodes[n].coord.x, self.nodes[child].coord.x]
ye = [self.nodes[n].coord.y, self.nodes[child].coord.y]
ze = [self.nodes[n].coord.z, self.nodes[child].coord.z]
ax.plot(xe, ye, ze, plot_color_board[self.nodes[n].depth % 5])
current_generation = next_generation
ax.scatter(xs, ys, zs, c="r", marker="o")
global_radius = self.nodes[self.root].radius * 1.12
if equators:
for axis in ["x", "y", "z"]:
circle = Circle((0, 0), global_radius * 1.1)
circle.set_clip_box(ax.bbox)
circle.set_edgecolor("gray")
circle.set_alpha(0.3)
circle.set_facecolor("none") # "none" not None
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0, zdir=axis)
ax.set_xlim([-1.2 * global_radius, 1.2 * global_radius])
ax.set_ylim([-1.2 * global_radius, 1.2 * global_radius])
ax.set_zlim([-1.2 * global_radius, 1.2 * global_radius])
ax.set_xlabel("X Label")
ax.set_ylabel("Y Label")
ax.set_zlabel("Z Label")
plt.show()
开发者ID:ee08b397,项目名称:hypy,代码行数:53,代码来源:tree.py
示例6: text3d
def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
x, y, z = xyz
if zdir == "y":
xy1, z1 = (x, z), y
elif zdir == "y":
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)
开发者ID:sballin,项目名称:filament,代码行数:13,代码来源:3d_plot.py
示例7: show
def show(self,label="Translations",label_q="Quaternions"):
"""
Display the transforms on a 3d plot.
"""
self.transform_transforms(self.plane_to_yz_transform)
self.transform_transforms(self.flatten_transform)
fig = plt.figure(label)
fig2 = plt.figure(label_q)
ax = fig.add_subplot(111,projection="3d",aspect=1)
ax_quats = fig2.add_subplot(111,projection="3d",aspect=1)
x = []; y = []; z = []
q_x = []; q_y = []; q_z = []
x_n = []; y_n = []; z_n = []
for translation,transform in zip(self.translations,self.transforms)[0::self.skip]:
if transform.is_valid:
x.append(translation[0])
y.append(translation[1])
z.append(translation[2])
if not transform.is_valid:
x_n.append(translation[0])
y_n.append(translation[1])
z_n.append(translation[2])
q_x.append(transform.q[0])
q_y.append(transform.q[1])
q_z.append(transform.q[2])
ax.scatter(x,y,z,color="b",s=200)
ax.scatter(x_n,y_n,z_n,color="r",s=200)
ax_quats.scatter(q_x,q_y,q_z,color="g",s=200)
if self.show_transform_axis:
for t in self.transforms[0::self.skip]:
a = Axis3D(t.transform)
for arrow in a.arrows:
ax.add_artist(arrow)
circle_axis = Arrow3D((0,self.circle.axis[0]),(self.circle.origin[1],self.circle.origin[1]+self.circle.axis[1]),(self.circle.origin[2],self.circle.origin[2]+self.circle.axis[2]),mutation_scale=20,lw=3,arrowstyle="-|>", color="g")
ax.add_artist(circle_axis)
circle = matplotlib.patches.Circle((self.circle.origin[1], self.circle.origin[2]), self.circle.radius,fill=False)
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0, zdir="x")
ax.auto_scale_xyz([-.5, .5], [-.5, .5], [-0, 1])
ax_quats.auto_scale_xyz([-.5, .5], [-.5, .5], [-0, 1])
plt.show()
self.transform_transforms(self.flatten_transform,inverse=True)
self.transform_transforms(self.plane_to_yz_transform,inverse=True)
开发者ID:hbradlow,项目名称:modelbuilder,代码行数:50,代码来源:transform_processor.py
示例8: plot_baseline_landscape_overlay
def plot_baseline_landscape_overlay(dlg, data, subj_id, trial_no):
dlp = dl_plotter.DLPlotter(elev=55, azim=-65)
x_grid, y_grid, dl = dlg.get_model_dl(dlg.model.get_baseline_params()*4)
x=(x_grid[1:]+x_grid[:-1])/2
y=(y_grid[1:]+y_grid[:-1])/2
f = interpolate.interp2d(x,y,dl,kind='cubic')
ax = dlp.plot_surface(x_grid, y_grid, dl, cmap=cm.viridis, alpha=0.9)
ax.set_xticks([-1, -0.5, 0, 0.5, 1])
ax.set_yticks([0, 0.5, 1])
ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.w_zaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.w_zaxis.set_ticklabels([])
sns.set_style('white')
cmap = cm.viridis
traj_color = cmap(0.1)
trajectory = data.loc[subj_id, trial_no]
z = f(trajectory.x.values, trajectory.y.values)
if trajectory.x.values[-1]>0:
z= np.diag(z)
else:
z=np.diag(np.fliplr(z))
# plot trajectory on a surface
ax.plot(trajectory.x.values, trajectory.y.values, z, color='black', alpha=0.5)
# plot marble
ax.plot([0.], [0.], [0.], marker='o', markersize=15, color = 'black', alpha=0.7)
ax.plot([trajectory.x.values[-1]], [trajectory.y.values[-1]], [z[-1]],
marker='o', markersize=15, color='black', alpha=0.7)
# draw screen above the surface and choice options on it
patches = get_choice_patches()
for patch in patches:
ax.add_patch(patch)
art3d.pathpatch_2d_to_3d(patch, z=0, zdir='z')
# plot trajectory on a screen
ax.plot(trajectory.x, trajectory.y, zs=0, zdir='z', color=traj_color, ls='none',
alpha=1.0, marker='o', ms=15, markerfacecolor='none', markeredgewidth=2,
markeredgecolor=traj_color, label='Mouse trajectory')
plt.savefig('figures/baseline_dlv.pdf')
开发者ID:cherepaha,项目名称:PyDSV,代码行数:49,代码来源:plot_sample_traj_and_dlv.py
示例9: _trimesh
def _trimesh(ax, t, x, y, z, **kwargs):
"""Display a 3D triangular mesh.
Ignores ax._hold.
"""
from mpl_toolkits.mplot3d.art3d import pathpatch_2d_to_3d
patches = []
code = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]
for f in t:
bdry = np.take(f, range(4), mode='wrap')
pp = PathPatch(Path(np.column_stack((x[bdry], y[bdry])), code),
**kwargs)
ax.add_patch(pp)
pathpatch_2d_to_3d(pp, z[bdry])
patches.append(pp)
return patches
开发者ID:bcrestel,项目名称:pydistmesh,代码行数:16,代码来源:plotting.py
示例10: plot_3D_cylinder
def plot_3D_cylinder(ax, radius, height, elevation=0, resolution=200, color='r', x_center=0, y_center=0):
x = np.linspace(x_center - radius, x_center + radius, resolution)
z = np.linspace(elevation, elevation + height, resolution)
X, Z = np.meshgrid(x, z)
Y = np.sqrt(radius ** 2 - (X - x_center) ** 2) + y_center # Pythagorean theorem
ax.plot_surface(X, Y, Z, linewidth=0, color=color)
ax.plot_surface(X, (2 * y_center - Y), Z, linewidth=0, color=color)
floor = Circle((x_center, y_center), radius, color=color)
ax.add_patch(floor)
art3d.pathpatch_2d_to_3d(floor, z=elevation, zdir="z")
ceiling = Circle((x_center, y_center), radius, color=color)
ax.add_patch(ceiling)
art3d.pathpatch_2d_to_3d(ceiling, z=elevation + height, zdir="z")
开发者ID:isomerase,项目名称:RoboSkeeter,代码行数:17,代码来源:plot_environment.py
示例11: show_stars
def show_stars(dt, range, count_show_with_legend, plot_name, scatter=False):
ax = plt.subplot(111, projection='3d')
ax.plot((0,), (0,), (0,), 'o', color='orange', markersize=10, label='sun')
ax.plot([0, range], [0, 0], [0, 0], label='to galaxy center')
arc = Arc((27200, 0, 0), SUN_TO_CENTER_DISTANCE * 2, SUN_TO_CENTER_DISTANCE * 2,
theta1=180 - np.degrees(range / SUN_TO_CENTER_DISTANCE),
theta2=180 + np.degrees(range / SUN_TO_CENTER_DISTANCE))
ax.add_patch(arc)
art3d.pathpatch_2d_to_3d(arc, z=0)
ax.plot([0, polaris["x"][0]], [0, polaris["y"][0]], [0, polaris["z"][0]], label='polaris')
if scatter:
ax.scatter(dt['x'], dt['y'], dt['z'], c=dt['vmag'], cmap=plt.cm.Spectral)
else:
counter = 0
for r in dt:
marker = mlines.Line2D.filled_markers[counter % mlines.Line2D.filled_markers.__len__()]
if counter < count_show_with_legend:
ax.plot([r["x"]], [r["y"]], [r["z"]], 'o',
label=r["name"] + " " + str(r["vmag"]) + " " + str(int(r["dist"])) + "ly",
markersize=5, marker=marker)
else:
ax.plot([r["x"]], [r["y"]], [r["z"]], '.', markersize=2)
counter += 1
try:
ax.legend(numpoints=1, fontsize=10) # call with fontsize fails on debian 7
except:
ax.legend(numpoints=1)
ax.set_xlabel('ly')
ax.set_ylabel('ly')
ax.set_zlabel('ly')
ax.auto_scale_xyz([-range, range], [-range, range], [-range, range])
show_maximized_plot(plot_name)
开发者ID:vovaprog,项目名称:python_space,代码行数:45,代码来源:stars.py
示例12: angle
def angle(ax, angle_center=(0, 0, 0), starting_angle=0.0, ending_angle=75, angle_width=0.1, angle_height=0.1):
p = Arc(angle_center[0:2], angle_width, angle_height, theta1=starting_angle, theta2=ending_angle)
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=angle_center[-1], zdir="y")
#examples below:
#ellipsoid(ax, 10,20,10)
#cylinder(ax, length=10, color='g', direction='y')
#box(ax, 5,10,5)
#ellipse(ax, rad_x=2, direction='x')
## Angle example:
#add_arrow3d(ax, [0.5, 0.75], [1, 1], [0, 1])
#plane(ax, color='r')
#angle(ax, (0.5, 0, 1), angle_width=0.5, angle_height=0.5)
#ax.set_axis_off()
#plt.show()
开发者ID:sci2u,项目名称:api,代码行数:18,代码来源:misc_3d_shapes.py
示例13: _plot_grid3d
def _plot_grid3d(ax, grid, bbox, planes):
"""Plots a 3D LB lattice.
:param ax: matplotlib Axes object to use for plotting
:param grid: Sailfish grid object to illustrate
:param bbox: if True, draw a blue 3D bounding box around the plot
:param planes: if True, draws planes passing through the origin
"""
assert grid.dim == 3
bb = 0
for ei in grid.basis[1:]:
a = Arrow3D(
*zip((0, 0, 0), [float(x) * 1.05 for x in ei]),
color='k',
arrowstyle='-|>',
mutation_scale=10,
lw=1)
ax.add_artist(a)
bb = max(bb, max([int(x) for x in ei]))
for i in ('x', 'y', 'z'):
c = Circle((0, 0), radius=0.05, color='k')
ax.add_patch(c)
art3d.pathpatch_2d_to_3d(c, z=0, zdir=i)
ax.set_xlim(-bb, bb)
ax.set_ylim(-bb, bb)
ax.set_zlim(-bb, bb)
if planes:
p1 = [(-bb, -bb, 0), (bb, -bb, 0), (bb, bb, 0), (-bb, bb, 0)]
p2 = [(0, -bb, -bb), (0, bb, -bb), (0, bb, bb), (0, -bb, bb)]
p3 = [(-bb, 0, -bb), (bb, 0, -bb), (bb, 0, bb), (-bb, 0, bb)]
ax.add_collection3d(
Poly3DCollection([p1, p2, p3], facecolor='b', lw=0, alpha=0.1))
if bbox:
r = [-bb, bb]
for s, e in combinations(np.array(list(product(r, r, r))), 2):
if np.sum(np.abs(s - e)) == r[1] - r[0]:
ax.plot3D(*zip(s, e), color='b', ls='--')
开发者ID:jabez1314,项目名称:sailfish,代码行数:42,代码来源:plot_util.py
示例14: scatter_points
def scatter_points( cloud, truth=None, ax=None ) :
if ax is None :
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
if truth is not None :
x,y,z = truth
rad = np.linalg.norm([x,y])
circ = patches.Circle( (0,0), rad, linestyle='dashed', fill=False )
ax.add_patch( circ )
art3d.pathpatch_2d_to_3d( circ, z )
ax.plot( [ 0, x ], [ 0, y ], [ 0, z ] )
ax.set_xlim3d(-rad,rad)
ax.set_ylim3d(-rad,rad)
cloud = np.vstack( cloud ).transpose()
ax.scatter( cloud[0,:], cloud[1,:], cloud[2,:] )
return ax
开发者ID:kyletreleaven,项目名称:em_particle_smoothing,代码行数:20,代码来源:radar.py
示例15: show_open_clusters
def show_open_clusters(messier,data,box_size):
ax = plt.subplot(111, projection='3d')
ax.plot([0], [0], [0], 'o', color='orange', markersize=10, label='sun')
circle = Circle((SUN_TO_CENTER_DISTANCE, 0, 0), SUN_TO_CENTER_DISTANCE, fill=False, color='blue')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
circle = Circle((SUN_TO_CENTER_DISTANCE, 0, 0), MILKY_WAY_RADIUS, fill=False, color='blue')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
if messier:
counter = 0
for r in data:
marker = mlines.Line2D.filled_markers[counter % mlines.Line2D.filled_markers.__len__()]
ax.plot([r["x"]], [r["y"]], [r["z"]], 'o', label=r["messier"] + " " + str(int(r["dist"])) + " ly", markersize=5, marker=marker)
counter += 1
try:
ax.legend(numpoints=1, fontsize=10) # call with fontsize fails on debian 7
except:
ax.legend(numpoints=1)
else:
ax.scatter(data["x"], data["y"], data["z"])
ax.set_xlabel('ly')
ax.set_ylabel('ly')
ax.set_zlabel('ly')
ax.auto_scale_xyz([-box_size, box_size], [-box_size, box_size], [-box_size, box_size])
show_maximized_plot('open clusters')
开发者ID:vovaprog,项目名称:python_space,代码行数:39,代码来源:open_clusters.py
示例16: text3d
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 == "y":
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)
开发者ID:AlexandreAbraham,项目名称:matplotlib,代码行数:24,代码来源:pathpatch3d_demo.py
示例17: __init__
def __init__(self):
win = gtk.Window()
win.set_default_size(800,800)
vbox = gtk.VBox()
win.add(vbox)
fig = Figure()
canvas = FigureCanvas(fig) # a gtk.DrawingArea
ax = fig.add_subplot(111, projection='3d')
a = np.array([[0,0],[10,0],[10,10],[0,10]])
p = Polygon(a,fill=True)
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=3)
ax.set_xlim3d(0, 20)
ax.set_ylim3d(0, 20)
ax.set_zlim3d(0, 20)
vbox.pack_start(canvas)
win.show_all()
# Run the Gtk mainloop
gtk.main()
开发者ID:Trineon,项目名称:lisa,代码行数:24,代码来源:resection.py
示例18: draw_rectangular_prism
def draw_rectangular_prism(ax, x_min, x_max, y_min, y_max, z_min, z_max):
alpha = 1
back = Rectangle((y_min, z_min), y_max - y_min, z_max, alpha=alpha, fill=None, linestyle='dotted')
ax.add_patch(back)
art3d.pathpatch_2d_to_3d(back, z=x_min, zdir="x")
front = Rectangle((y_min, z_min), y_max - y_min, z_max, alpha=alpha, fill=None, linestyle='dotted')
ax.add_patch(front)
art3d.pathpatch_2d_to_3d(front, z=x_max, zdir="x")
floor = Rectangle((x_min, y_min), x_max, z_max, alpha=alpha, fill=None, linestyle='dotted')
ax.add_patch(floor)
art3d.pathpatch_2d_to_3d(floor, z=z_min, zdir="z")
ceiling = Rectangle((x_min, y_min), x_max, z_max, alpha=alpha, fill=None, linestyle='dotted')
ax.add_patch(ceiling)
art3d.pathpatch_2d_to_3d(ceiling, z=z_max, zdir="z")
开发者ID:sazamore,项目名称:RoboSkeeter,代码行数:17,代码来源:plot_environment.py
示例19: show_globular_clusters
def show_globular_clusters(dt, messier):
ax = plt.subplot(111, projection='3d')
ax.plot((0,), (0,), (0,), 'o', color='orange', markersize=7, label='sun')
circle = Circle((SUN_TO_CENTER_DISTANCE, 0, 0), SUN_TO_CENTER_DISTANCE, fill=False, color='blue')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
circle = Circle((SUN_TO_CENTER_DISTANCE, 0, 0), MILKY_WAY_RADIUS, fill=False, color='blue')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
circle = Circle((0, 0, 0), 1000, fill=False, color='red')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
if messier:
counter = 0
for r in dt:
marker = mlines.Line2D.filled_markers[counter % mlines.Line2D.filled_markers.__len__()]
if r["messier"] > 0:
ax.plot([r["x"]], [r["y"]], [r["z"]], 'o', label="M" + str(r["messier"]) + " " + str(int(r["dist"])), markersize=5, marker=marker)
counter += 1
try:
ax.legend(numpoints=1, fontsize=10) # call with fontsize fails on debian 7
except:
ax.legend(numpoints=1)
else:
ax.scatter(dt['x'], dt['y'], dt['z'])
ax.set_xlabel('ly')
ax.set_ylabel('ly')
ax.set_zlabel('ly')
ax.auto_scale_xyz([-35000, 85000], [-60000, 60000], [-60000, 60000])
show_maximized_plot('globular clusters')
开发者ID:vovaprog,项目名称:python_space,代码行数:44,代码来源:globular_clusters.py
示例20: show_globular_clusters
def show_globular_clusters(dt, messier):
ax = plt.subplot(111, projection='3d')
ax.plot((0,), (0,), (0,), 'o', color='orange', markersize=7, label='sun')
circle = Circle((SUN_TO_CENTER_DISTANCE, 0, 0), SUN_TO_CENTER_DISTANCE, fill=False, color='blue')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
circle = Circle((SUN_TO_CENTER_DISTANCE, 0, 0), MILKY_WAY_RADIUS, fill=False, color='blue')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
circle = Circle((0, 0, 0), 1000, fill=False, color='red')
ax.add_patch(circle)
art3d.pathpatch_2d_to_3d(circle, z=0)
if messier:
counter = 0
for r in dt:
marker = mlines.Line2D.filled_markers[counter % mlines.Line2D.filled_markers.__len__()]
if str(r["Name"]).startswith('M'):
ax.plot([r["X"]], [r["Y"]], [r["Z"]], 'o', label=str(r["Name"]) + " " + str(r["Rsun"]), markersize=5, marker=marker)
counter += 1
ax.legend(numpoints=1, fontsize=10)
else:
ax.scatter(dt['X'], dt['Y'], dt['Z'])
ax.set_xlabel('ly')
ax.set_ylabel('ly')
ax.set_zlabel('ly')
ax.auto_scale_xyz([-35000, 85000], [-60000, 60000], [-60000, 60000])
show_maximized_plot('globular clusters')
开发者ID:vovaprog,项目名称:python_space,代码行数:40,代码来源:globular_clusters_astroquery.py
注:本文中的mpl_toolkits.mplot3d.art3d.pathpatch_2d_to_3d函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论