当前位置: 首页>>代码示例>>Python>>正文


Python Ellipse.set_linestyle方法代码示例

本文整理汇总了Python中matplotlib.patches.Ellipse.set_linestyle方法的典型用法代码示例。如果您正苦于以下问题:Python Ellipse.set_linestyle方法的具体用法?Python Ellipse.set_linestyle怎么用?Python Ellipse.set_linestyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.patches.Ellipse的用法示例。


在下文中一共展示了Ellipse.set_linestyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_aperture

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linestyle [as 别名]
	def plot_aperture(self,scale=3.0):
		from matplotlib import pyplot as plt
		from matplotlib.patches import Ellipse
		import matplotlib.cm as cmap
		prop=self.properties()
		r_slc=self.r[self.obj_slice[0]]
		c_slc=self.c[self.obj_slice[1]]
		nr,nc=len(r_slc),len(c_slc)
		x=prop['X_Cen']-1.0
		y=prop['Y_Cen']-1.0
		a=prop['A']
		b=prop['B']
		t=prop['PA']
		x=(x-c_slc[0])/(c_slc[-1]-c_slc[0])*nc
		y=(y-r_slc[0])/(r_slc[-1]-r_slc[0])*nr
		a=a*nc/(c_slc[-1]-c_slc[0])
		b=b*nr/(r_slc[-1]-r_slc[0])
		print('x y a b theta: ',x,y,a,b,t)
		e=Ellipse((x,y),a*scale,b*scale,angle=t)
		e.set_linestyle('solid')
		e.set_edgecolor('r')
		e.set_facecolor('none')
		e1=Ellipse((x,y),a*scale,b*scale,angle=t)
		e1.set_linestyle('solid')
		e1.set_edgecolor('r')
		e1.set_facecolor('none')
		
		data_slc=self.data[self.obj_slice]
		udata_slc=self.udata[self.obj_slice]
		mask_slc=self.mask
		if mask_slc is None:
			mask_slc=False
		if not np.isscalar(mask_slc):
			mask_slc=self.mask[self.obj_slice]

		fig, axes = plt.subplots(nrows=1, ncols=3)
		ax1,ax2,ax3=axes.ravel()
			
		ax1.imshow(udata_slc,vmin=udata_slc.min(),vmax=udata_slc.max(),origin='lower',cmap=cmap.get_cmap('gray_r'))
		ax1.set_title('data uncertainty')
		ax2.imshow((data_slc*(np.logical_not(mask_slc))),vmin=data_slc.min(),vmax=data_slc.max(),origin='lower',cmap=cmap.get_cmap('gray_r'))
		ax2.set_title('masked data')
		ax2.add_artist(e)
		ax3.imshow(data_slc,vmin=data_slc.min(),vmax=data_slc.max(),origin='lower',cmap=cmap.get_cmap('gray_r'))
		ax3.set_title('data with ellipse')
		ax3.add_artist(e1)
		plt.show()
开发者ID:zouhu,项目名称:astrophot,代码行数:49,代码来源:detection.py

示例2: Ellipse

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linestyle [as 别名]
  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)

  ax.text(1, 9, str(z)+'m, '+str(time[t]/3600)+'h', fontsize=18)

  plt.savefig('./plot/'+exp+'/traj_'+exp+'_z'+str(z)+'_'+str(time[t]/3600)+'_h.eps')
  print       './plot/'+exp+'/traj_'+exp+'_z'+str(z)+'_'+str(time[t]/3600)+'_h.eps'
  plt.close()
 
开发者ID:jungla,项目名称:ICOM-fluidity-toolbox,代码行数:32,代码来源:plot_traj_hv.py

示例3: test

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linestyle [as 别名]
def test():
	from astropy.modeling.models import Gaussian2D
	from matplotlib import pyplot as plt
	from matplotlib.patches import Ellipse
	import matplotlib.cm as cmap
	import numpy.random as nrd
	import random as rd
	nx=500       # 
	ny=500       # image size
	xmin=-5.0    # row/column range
	xmax=5.0
	ymin=-5.0
	ymax=5.0	 # 
	amp=20.0      # gaussian amplitude
	xm=0.0       # row mean
	ym=-0.0      # column mean
	xsig=1.0     # row sigma
	ysig=0.3
	offset=3.0   # gaussian offset
	theta=np.random.uniform(0,360) # rotation angle

	gmodel=Gaussian2D
	x=np.linspace(xmin,xmax,nx)
	y=np.linspace(ymin,ymax,ny)
	xx,yy=np.meshgrid(x,y)

	gvals=gmodel.evaluate(xx,yy,amplitude=amp,x_mean=xm,y_mean=ym,x_stddev=xsig,y_stddev=ysig,theta=np.deg2rad(theta))+offset
	#nrd.seed(500000)
	nrd.seed()
	noise=np.sqrt(gvals)*nrd.randn(ny,nx)
	#rd.seed(500000)
	rd.seed()
	indrand=np.array(rd.sample(range(nx*ny),nx*ny//10))
	indx,indy=np.unravel_index(indrand,(nx,ny))
	mask=np.repeat(False,nx*ny).reshape(ny,nx)
	mask[indy,indx]=True
	model=gvals+noise
	
	dp=DetectionProperties(model-offset,np.abs(noise),mask=mask,r=y,c=x)
	dp.plot_aperture(scale=5.0)
	prop=dp.properties()
	r_slc=dp.r[dp.obj_slice[0]]
	c_slc=dp.c[dp.obj_slice[1]]
	nr=len(r_slc)
	nc=len(c_slc)
	print(prop)
	print('center (original):',xm,ym)
	print('center (calculate):',prop['X_Cen'],prop['Y_Cen'])
	print('x_sig,ysig (original):',xsig,ysig)
	print('x_sig,ysig (calculate):',prop['A'],prop['B'])
	print('B/A (original):',ysig/xsig)
	print('B/A (calculate):',prop['B']/prop['A'])
	print('theta (original):',theta)
	print('theta (calculate):',prop['PA'])
	

	#plt.figure(figsize=(800,800))
	#fig, axes = plt.subplots(nrows=2, ncols=2)
	#import numpy as np
	#import matplotlib.pyplot as plt

	#fig, axes = plt.subplots(nrows=2, ncols=2)
	#for ax in axes.flat:
	#	    im = ax.imshow(np.random.random((10,10)), vmin=0, vmax=1)

	#fig.subplots_adjust(right=0.8)
	#cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
	#fig.colorbar(im, cax=cbar_ax)

	#plt.show()
			
	fig, axes = plt.subplots(nrows=2, ncols=2)
	ax1,ax2,ax3,ax4=axes.ravel()
	ax1.imshow(gvals,vmin=3.0,vmax=25,origin='lower',cmap=cmap.get_cmap('gray_r'))
	ax1.set_title('model')
	ax2.imshow(noise,vmin=3.0,vmax=25,origin='lower',cmap=cmap.get_cmap('gray_r'))
	ax2.set_title('noise')

	x0=(prop['X_Cen']-c_slc[0])/(c_slc[-1]-c_slc[0])*nc
	y0=(prop['Y_Cen']-r_slc[0])/(r_slc[-1]-r_slc[0])*nr
	x1=(xm-xmin)/(xmax-xmin)*nc
	y1=(ym-ymin)/(ymax-ymin)*nr
	a0=prop['A']/(c_slc[-1]-c_slc[0])*nc
	b0=prop['B']/(r_slc[-1]-r_slc[0])*nr
	t0=prop['PA']
	a1=xsig/(xmax-xmin)*nc
	b1=ysig/(ymax-ymin)*nr
	t1=theta
	elp0=Ellipse((x0,y0),a0*5,b0*5,angle=t0)
	elp00=Ellipse((x0,y0),a0*5,b0*5,angle=t0)
	elp1=Ellipse((x1,y1),a1*5,b1*5,angle=t1)
	print(x0,y0,a0,b0,t0)
	print(x1,y1,a1,b1,t1)

	ax3.imshow(model,vmin=3.0,vmax=25,origin='lower',cmap=cmap.get_cmap('gray_r'))
	ax3.set_title('model+noise')
	ax3.add_artist(elp0)
	elp0.set_linestyle('dashed')
	elp0.set_edgecolor('g')
	elp0.set_facecolor('none')
#.........这里部分代码省略.........
开发者ID:zouhu,项目名称:astrophot,代码行数:103,代码来源:detection.py

示例4: corrplot

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_linestyle [as 别名]
def corrplot(data, pvalues, labels):
    """Creates a correlation plot of the passed data.

    The function returns the plot which can then be shown with
    plot.show(), saved to a file with plot.savefig(), or manipulated
    in any other standard matplotlib way.

    data is the correlation matrix, a 2-D numpy array containing
    the pairwise correlations between variables;

    pvalues is a matrix containing the pvalue for each corresponding
    correlation value; if none it is assumed to be the zero matrix

    labels is an array containing the variable names
    """

    plt.figure(1)

    column_labels = labels
    row_labels = labels
    
    ax = plt.subplot(1, 1, 1, aspect='equal')

    width, height = data.shape
    num_cols, num_rows = width, height

    if pvalues is None:
        pvalues = np.zeros([num_rows, num_cols])
        
    shrink = 0.9

    poscm = cm.get_cmap('Blues')
    negcm = cm.get_cmap('Oranges')

    for x in xrange(width):
        for y in xrange(height):
            d = data[x, y]
            c = pvalues[x, y]
            rotate = -45 if d > 0 else +45
            clrmap = poscm if d >= 0 else negcm
            d_abs = np.abs(d)
            ellipse = Ellipse((x, y),
                              width=1 * shrink,
                              height=(shrink - d_abs*shrink),
                              angle=rotate)
            ellipse.set_edgecolor('black')
            ellipse.set_facecolor(clrmap(d_abs))
            if c > 0.05:
                ellipse.set_linestyle('dotted')
            ax.add_artist(ellipse)

    ax.set_xlim(-1, num_cols)
    ax.set_ylim(-1, num_rows)
        
    ax.xaxis.tick_top()
    xtickslocs = np.arange(len(row_labels))
    ax.set_xticks(xtickslocs)
    ax.set_xticklabels(row_labels, rotation=30, fontsize='small', ha='left')

    ax.invert_yaxis()
    ytickslocs = np.arange(len(row_labels))
    ax.set_yticks(ytickslocs)
    ax.set_yticklabels(column_labels, fontsize='small')

    return plt
开发者ID:bkarak,项目名称:data_paper_msr2014,代码行数:67,代码来源:corrplot.py


注:本文中的matplotlib.patches.Ellipse.set_linestyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。