本文整理汇总了Python中matplotlib.patches.Ellipse.set_lw方法的典型用法代码示例。如果您正苦于以下问题:Python Ellipse.set_lw方法的具体用法?Python Ellipse.set_lw怎么用?Python Ellipse.set_lw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Ellipse
的用法示例。
在下文中一共展示了Ellipse.set_lw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UVellipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_lw [as 别名]
def UVellipse(u,v,w,a,b,v0):
fig=plt.figure(0)
e1=Ellipse(xy=np.array([0,v0]),width=2*a,height=2*b,angle=0)
e2=Ellipse(xy=np.array([0,-v0]),width=2*a,height=2*b,angle=0)
ax=fig.add_subplot(111,aspect="equal")
ax.plot([0],[v0],"go")
ax.plot([0],[-v0],"go")
ax.plot(u[0],v[0],"bo")
ax.plot(u[-1],v[-1],"bo")
ax.plot(-u[0],-v[0],"ro")
ax.plot(-u[-1],-v[-1],"ro")
ax.add_artist(e1)
e1.set_lw(1)
e1.set_ls("--")
e1.set_facecolor("w")
e1.set_edgecolor("b")
e1.set_alpha(0.5)
ax.add_artist(e2)
e2.set_lw(1)
e2.set_ls("--")
e2.set_facecolor("w")
e2.set_edgecolor("r")
e2.set_alpha(0.5)
ax.plot(u,v,"b")
ax.plot(-u,-v,"r")
ax.hold('on')
示例2: covarianceEllipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_lw [as 别名]
def covarianceEllipse(mean, covar, scale=1.0):
eval, evec = np.linalg.eig(covar)
angles = np.degrees(np.arctan(evec[1,:] / evec[0,:]))
q1 = np.flatnonzero((angles >= 0) & (angles < 90))[0]
q2 = 1 - q1
q1Angle = angles[q1]
q1Length = np.sqrt(eval[q1])
q2Length = np.sqrt(eval[q2])
e = Ellipse(xy=mean, angle=q1Angle,
width=q1Length*scale, height=q2Length*scale)
e.set_fill(False)
e.set_edgecolor("black")
e.set_alpha(1.0)
e.set_lw(2)
e.set_ls("dashed")
return e
示例3: plot_cluster_pos
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_lw [as 别名]
def plot_cluster_pos(ecc, fname):
a = 1
b = a*(1-ecc)/(1+ecc)
xe = 0
ye = -a*ecc
e = Ellipse((0,0), 2*b, 2*a)
phi = pi/4 - pi/10
xc = b*cos(phi)
yc = a*sin(phi)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_aspect('equal')
ax.add_patch(e)
e.set_clip_box(ax.bbox)
e.set_facecolor([1,1,1])
e.set_ec('w')
e.set_fc('none')
e.set_lw(1)
plt.plot(xc,yc,'ow',ms = 10)
plt.text(xc-0.1, yc-0.2, 'Cluster',fontsize = 11,color = 'w')
plt.plot(xe,ye,'ow',ms = 10)
plt.text(xe-0.5, ye - 0.2, 'Galactic Center',fontsize = 11,color = 'w')
dphi = pi/40
plt.arrow(b*cos(phi+dphi),
a*sin(phi+dphi),
-b*sin(phi+dphi)*0.0001,
a*cos(phi+dphi)*0.0001,
width = 0.001,
head_width = 0.04,
head_starts_at_zero = True,
fill = False,
overhang = 0.9,
color = 'w')
phis = pi/2
xs = xc + cos(phis)*a/5.
ys = yc + sin(phis)*a/5.
plt.plot(xs, ys, '*w', ms = 10)
plt.text(xs-0.1, ys+0.1, 'Star',fontsize = 11,color = 'w')
plt.plot([xe,xc],[ye,yc],'--w')
plt.text((b*cos(phi)*0.5)*0.6+0.1, (a*sin(phi)*0.1-0.05), '$\mathbf{R}$',color = 'w')
plt.plot([xe,xs],[ye,ys],'--w')
plt.text((xs+xe)/2, (ys+ye)/2+0.1, '$\mathbf{x}$',color = 'w')
plt.plot([xc,xs],[yc,ys],':w')
plt.text((xc+xs)/2+0.05, (yc+ys)/2-0.01, '$\mathbf{r}$',color = 'w')
plt.arrow(xc, yc, (xc-xe)*.5, (yc-ye)*.5,
color = 'w', width = 0.001, head_width = 0.03)
plt.arrow(xc, yc, -(yc-ye)*.5, (xc-xe)*.5,
color = 'w', width = 0.001, head_width = 0.03)
plt.text(xc + (xc-xe)*.5+0.03, yc + (yc-ye)*.5 - 0.02, '$x$',color = 'w')
plt.text(xc - (yc-ye)*.5-0.05, yc + (xc-xe)*.5+0.05, '$y$',color = 'w')
ax.set_ylim((ye-(1-ecc)*a)*1.4, (ye+(1+ecc)*a)*1.4)
ax.set_xlim(-a*1.4, a*1.4)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
ax.set_frame_on(False)
set_foregroundcolor(ax,'w')
set_backgroundcolor(ax,'k')
plt.savefig(fname, bbox_inches = 'tight',transparent = True)