本文整理汇总了Python中matplotlib.patches.Ellipse.set_linewidth方法的典型用法代码示例。如果您正苦于以下问题:Python Ellipse.set_linewidth方法的具体用法?Python Ellipse.set_linewidth怎么用?Python Ellipse.set_linewidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Ellipse
的用法示例。
在下文中一共展示了Ellipse.set_linewidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: error_ellipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
def error_ellipse(self, i, j, nstd=1, space_factor=5.0, clr="b", alpha=0.5, lw=1.5):
"""
return the plot of the error ellipse from the covariance matrix
use ideas from error_ellipse.m from
http://www.mathworks.com/matlabcentral/fileexchange/4705-error-ellipse
( the version used here was taken from an earlier version, it looks to have been updated there to a new version.)
* (i,j) specify the ith and jth parameters to be used and
* nstd specifies the number of standard deviations to plot, the default is 1 sigma.
* space_factor specifies the number that divides the width/height, the result of which is then added as extra space to the figure
"""
def eigsorted(cov):
vals, vecs = np.linalg.eigh(cov)
order = vals.argsort()[::1]
return vals[order], vecs[:, order]
self.marginalize(param_list=[i, j])
vals, vecs = eigsorted(self.marginal_covariance_matrix)
theta = np.degrees(np.arctan2(*vecs[:, 0][::-1]))
# print theta
width, height = 2 * nstd * np.sqrt(vals)
xypos = [self.parameter_values[i], self.parameter_values[j]]
ellip = Ellipse(xy=xypos, width=width, height=height, angle=theta, color=clr, alpha=alpha)
# ellip.set_facecolor("white")
ellip.set_linewidth(lw)
ellip_vertices = ellip.get_verts()
xl = [ellip_vertices[k][0] for k in range(len(ellip_vertices))]
yl = [ellip_vertices[k][1] for k in range(len(ellip_vertices))]
dx = (max(xl) - min(xl)) / space_factor
dy = (max(yl) - min(yl)) / space_factor
xyaxes = [min(xl) - dx, max(xl) + dx, min(yl) - dy, max(yl) + dy]
return ellip, xyaxes
示例2: __init__
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
def __init__(self, x, y, dx, dy, border_tol=0.2, resize=True, plotview=None, **opts):
shape = Ellipse((float(x),float(y)), dx, dy, **opts)
if 'linewidth' not in opts:
shape.set_linewidth(1.0)
if 'facecolor' not in opts:
shape.set_facecolor('r')
super(NXellipse, self).__init__(shape, border_tol, resize, plotview)
self.shape.set_label('Ellipse')
self.ellipse = self.shape
示例3: draw
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
def draw(self, axes, figure, color):
mycirc = Ellipse(self.center, self.width, self.height, facecolor='none', edgecolor=color)
mycirc.set_linewidth(1)
mycirc.set_alpha(1)
mycirc.set_facecolor('none')
mycirc.set_hatch('//')
circ = axes.add_artist(mycirc)
figure.canvas.draw()
return circ
示例4: draw_storms
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
def draw_storms(storms, ax=None):
if ax == None:
fig = plt.figure()
ax = fig.add_subplot(111)
for s in storms:
ellps = Ellipse(xy=s['centroid'], width=s['majlen'], height=s['minlen'],
angle=s['angle'])
ax.add_artist(ellps)
ellps.set_clip_box(ax.bbox)
ellps.set_alpha(0.8)
ellps.set_facecolor('None')
ellps.set_edgecolor('red')
ellps.set_linewidth(3)
plt.draw()
示例5: Ellipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
theta3 = np.rad2deg(0.5*np.arctan2(2*cov3[1,0],(cov3[0,0]-cov3[1,1])))
theta3 = np.rad2deg(np.arcsin(v[0, 0]))
#
cov2 = np.cov(xt2/1000, yt2/1000)
lambda_2, v = np.linalg.eig(cov2)
lambda_2 = np.sqrt(lambda_2)
theta2 = np.rad2deg(0.5*np.arctan2(2*cov2[1,0],(cov2[0,0]-cov2[1,1]))) + np.pi*0.5
theta2 = np.rad2deg(np.arcsin(v[0, 0]))
#
e0 = Ellipse(xy=(np.mean(par3Dz[:,0,t])/1000,np.mean(par3Dz[:,1,t])/1000),width=4*lambda_3[1],height=4*lambda_3[0],angle=theta3)
e1 = Ellipse(xy=(np.mean(par2Dz[:,0,t])/1000,np.mean(par2Dz[:,1,t])/1000),width=4*lambda_2[1],height=4*lambda_2[0],angle=theta2)
ax.add_artist(e0)
e0.set_facecolor('none')
e0.set_edgecolor('k')
e0.set_linewidth(2.5)
ax.add_artist(e1)
e1.set_facecolor('none')
e1.set_edgecolor('k')
e1.set_linewidth(2.5)
e1.set_linestyle('dashed')
plt.xlim([-20, 20])
plt.ylim([-20, 20])
plt.xlabel('X [km]',fontsize=18)
plt.ylabel('Y [km]',fontsize=18)
plt.xticks(fontsize=16)
plt.yticks(fontsize=16)
# plt.title(str(time/3)+' hr',fontsize=18)
示例6: TestSingleCellPlot
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
def TestSingleCellPlot(extractor):
extractor.basic_props(splineSmooth)
extractor.shape_props()
extractor.cell_centre_fit()
padding = 10
fixed_perim = NP.transpose(extractor.perim_img)
perim_img_ind = NP.where(fixed_perim == 1)
xlim_min = min(perim_img_ind[1])
xlim_max = max(perim_img_ind[1])
ylim_min = min(perim_img_ind[0])
ylim_max = max(perim_img_ind[0])
U = extractor.spl_u
OUT = interpolate.splev(U, extractor.spl_poly)
BDY_FEATS = extractor.bdy_fvector
# Create Circle/Ellipse plot
fig = PLT.figure(1)
ax = fig.add_subplot(111, aspect='equal')
# Create circle plot
c = PLT.Circle((extractor.ccm_fvector[0],
extractor.ccm_fvector[1]),
extractor.ccm_fvector[2])
xlim_min = min(xlim_min, extractor.ccm_fvector[0] - extractor.ccm_fvector[2])
xlim_max = max(xlim_max, extractor.ccm_fvector[0] + extractor.ccm_fvector[2])
ylim_min = min(ylim_min, extractor.ccm_fvector[1] - extractor.ccm_fvector[2])
ylim_max = max(ylim_max, extractor.ccm_fvector[1] + extractor.ccm_fvector[2])
# Create ellipse plot
e = Ellipse(xy=NP.array([extractor.ellipse_fvector[0], extractor.ellipse_fvector[1]]),
width = extractor.ellipse_fvector[4],
height = extractor.ellipse_fvector[3],
angle = extractor.ellipse_fvector[5]/(2*NP.pi)*360)
# Compute horizontal width and height of the oriented ellipse
a = extractor.ellipse_fvector[4]/2.0
b = extractor.ellipse_fvector[3]/2.0
alpha = extractor.ellipse_fvector[5]
x_c = extractor.ellipse_fvector[0]
y_c = extractor.ellipse_fvector[1]
x_b = 0
y_b = 0
if a > b:
x_b = abs(a * math.cos(alpha))
y_b = abs(a * math.cos(alpha))
else:
x_b = abs(b * math.sin(alpha))
y_b = abs(b * math.cos(alpha))
xlim_min = min(xlim_min, x_c - x_b)
xlim_max = max(xlim_max, x_c + x_b)
ylim_min = min(ylim_min, y_c - y_b)
ylim_max = max(ylim_max, y_c + y_b)
PLT.imshow(fixed_perim, interpolation='nearest', cmap='Greys')
perimeter = conv_distance(extractor.perim_3pv)[0]
PLT.xticks([])
PLT.yticks([])
PLT.plot(extractor.perim_coord_poly[:,0], extractor.perim_coord_poly[:,1], label='Polygon Fit (Perimeter = %.2f um)'%perimeter, color='g', lw=2)
ax.add_artist(c)
c.set_alpha(1)
c.set_facecolor('none')
c.set_edgecolor('blue')
c.set_linewidth(3)
c.set_label('Circle')
ax.add_artist(e)
e.set_alpha(1)
e.set_facecolor('none')
e.set_edgecolor('orange')
e.set_linewidth(3)
e.set_label('Ellipse')
PLT.plot(0, 0, color='blue', label='Circle Fit (Variance = %.2f)'%extractor.ccm_fvector[5], lw=2)
PLT.plot(0, 0, color='orange', label='Ellipse Fit (Variance = %.2f)'%extractor.ellipse_fvector[8], lw=2)
lgd = PLT.legend(bbox_to_anchor=(0.0, 1.1, 1.0, 1.5), loc=3, ncol=1, mode=None, fontsize="small", borderaxespad=0.2, fancybox=True, shadow=True)
ax.set_xlim([xlim_min - padding, xlim_max + padding])
ax.set_ylim([ylim_min - padding, ylim_max + padding])
PLT.xticks([])
PLT.yticks([])
PLT.savefig(outFolder + pifFileName + '_Fits.png', bbox_extra_artists=(lgd,), bbox_inches='tight', dpi = 400)
# Create spline plot with boundary color based on magnitude and parity of curvature
fig, (ax1, ax2) = PLT.subplots(1, 2, gridspec_kw = {'width_ratios':[1,10]})
knorm = expit(extractor.spl_k/max(abs(extractor.spl_k))*10)
norm = matplotlib.colors.Normalize(vmin=NP.min(extractor.spl_k), vmax=NP.max(extractor.spl_k))
#.........这里部分代码省略.........
示例7: Ellipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
cov2 = np.cov(xt2, yt2)
lambda_2, v = np.linalg.eig(cov2)
lambda_2 = np.sqrt(lambda_2)
theta2 = np.rad2deg(0.5*np.arctan2(2*cov2[1,0],(cov2[0,0]-cov2[1,1])))
# [theta3,maj3,min3] = princax.princax(xt3+yt3*1j)
# [theta2,maj2,min2] = princax.princax(xt2+yt2*1j)
e0 = Ellipse(xy=(np.mean(par3Dz[:,0,t])/1000,np.mean(par3Dz[:,1,t])/1000),width=2*lambda_3[0]/1000,height=2*lambda_3[1]/1000,angle=theta3)
e1 = Ellipse(xy=(np.mean(par2Dz[:,0,t])/1000,np.mean(par2Dz[:,1,t])/1000),width=2*lambda_2[0]/1000,height=2*lambda_2[1]/1000,angle=theta2)
ax.add_artist(e0)
e0.set_facecolor('none')
e0.set_edgecolor('k')
e0.set_linewidth(1.5)
ax.add_artist(e1)
e1.set_facecolor('none')
e1.set_edgecolor('k')
e1.set_linewidth(1.5)
e1.set_linestyle('dashed')
plt.xlim([0, 5])
plt.ylim([0, 5])
plt.xlabel('X [km]',fontsize=18)
plt.ylabel('Y [km]',fontsize=18)
plt.xticks(fontsize=16)
plt.yticks(fontsize=16)
plt.title(str(time/3)+' hr',fontsize=18)
plt.savefig('./plot/m_50_6_23D/traj_Tr_'+exp2D+'_z'+str(depths[z])+'_'+str(time)+'_h.eps')
示例8: ROIellipse
# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linewidth [as 别名]
class ROIellipse(ROIcircle):
def __getstate__(self):
return {'im':self.im, 'circle':(self.center, self.width, self.height), 'color': self.color}
def __setstate__(self, d):
self.im = d['im']
self.center, self.width, self.height = d['circle']
self.circ = Ellipse(*d['circle'], facecolor='none', edgecolor=self.color)
self.color = self.color
self.patch = None
def draw(self, axes, figure, color):
mycirc = Ellipse(self.center, self.width, self.height, facecolor='none', edgecolor=color)
mycirc.set_linewidth(1)
mycirc.set_alpha(1)
mycirc.set_facecolor('none')
mycirc.set_hatch('//')
circ = axes.add_artist(mycirc)
figure.canvas.draw()
return circ
def motion_notify_callback(self, event):
"""Draw a line from the last selected point to current pointer
position. If left button is held, add points to the coords list
at each movement.
"""
if event.inaxes:
x, y = event.xdata, event.ydata
if event.button == None and self.circ is not None: # Move line around
x0, y0 = self.circ.center
self.circ.height = abs(y-y0)*2
self.circ.width = abs(x-x0)*2
self.fig.canvas.draw()
def button_press_callback(self, event):
"""Left button: add point; middle button: delete point;
right button: fill polygon and stop interaction.
"""
if event.inaxes:
x, y = event.xdata, event.ydata
ax = event.inaxes
if event.button == 1: # If you press the left button
if self.circ == None:
self.circ = Ellipse((x, y), 0.5, 0.5, facecolor='none', edgecolor=self.color)
self.center = x, y
ax.add_artist(self.circ)
else:
self.circ.set_color(self.color)
self.circ.set_edgecolor(self.color)
self.circ.set_facecolor('none')
self.circ.set_linewidth(1)
self.circ.set_alpha(1)
self.circ.set_hatch('//')
self.disconnect()
self.height = self.circ.height
self.width = self.circ.width
self.completion_callback()
elif event.button == 3 and self.circ is not None: # middle button: remove last segment
self.circ.remove()
self.circ = None
self.fig.canvas.draw()
def get_coords(self):
"""Returns the x,y coordinates of that have been selected
so far."""
if not self.center:
raise ValueError("cannot get ellipse coordinates before the dimensions are defined")
return self.center, self.width, self.height
def get_indices(self):
"""Returns a set of points that lie inside the picked polygon."""
if not self.center:
raise ValueError("Cannot get ellipse indices before the dimensions are defined")
x, y = self.center
w = self.width
h = self.height
return ellipse(y, x, h/2., w/2., self.im)