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


Python Ellipse.set_zorder方法代码示例

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


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

示例1: rectSelection

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_zorder [as 别名]
class rectSelection(GuiSelection):
    """Interactive selection of a rectangular region on the axis.

    Used by hist2d_alex().
    """
    def on_press_draw(self):
        if 'r' in self.__dict__:
            self.r.set_height(0)
            self.r.set_width(0)
            self.r.set_xy((self.xs, self.ys))
            self.e.height = 0
            self.e.width = 0
            self.e.center = (self.xs, self.ys)
        else:
            self.r = Rectangle(xy=(self.xs, self.ys), height=0, width=0,
                               fill=False, lw=2, alpha=0.5, color='blue')
            self.e = Ellipse(xy=(self.xs, self.ys), height=0, width=0,
                    fill=False, lw=2, alpha=0.6, color='blue')
            self.ax.add_artist(self.r)
            self.ax.add_artist(self.e)
            self.r.set_clip_box(self.ax.bbox)
            self.r.set_zorder(10)
            self.e.set_clip_box(self.ax.bbox)
            self.e.set_zorder(10)

    def on_motion_draw(self):
        self.r.set_height(self.ye - self.ys)
        self.r.set_width(self.xe - self.xs)
        self.e.height = (self.ye - self.ys)
        self.e.width = (self.xe - self.xs)
        self.e.center = (np.mean([self.xs, self.xe]),
                         np.mean([self.ys, self.ye]))
        self.fig.canvas.draw()

    def on_release_print(self):
        # This is the only custom method for hist2d_alex()
        E1, E2 = min((self.xs, self.xe)), max((self.xs, self.xe))
        S1, S2 = min((self.ys, self.ye)), max((self.ys, self.ye))
        self.selection = dict(E1=E1, E2=E2, S1=S1, S2=S2)
        pprint("Selection: \nE1=%.2f, E2=%.2f, S1=%.2f, S2=%.2f\n" %\
                (E1,E2,S1,S2))
开发者ID:pkw0818,项目名称:FRETBursts,代码行数:43,代码来源:gui_selection.py

示例2: make_newartist

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_zorder [as 别名]
    def make_newartist(self):
        self.check_loaded_gp_data()
        x1, y1=self.get_gp(0).get_device_point()
        x2, y2=self.get_gp(1).get_device_point()

        xy = ((x1+x2)/2, (y1+y2)/2)
        w = abs(x1-x2)
        h = abs(y1-y2)
        if self.getp("isotropic"):
           if w>h: w=h
           else: h = w
        a = Ellipse(xy, w, h, angle = self.getp('angle'),
                      facecolor='none', fill=False,
                      edgecolor='black', alpha=1)

        lp=self.getp("loaded_property") 
        if lp is not None:
             self.set_artist_property(a, lp[0])
             self.delp("loaded_property") 
        a.figobj=self
        a.figobj_hl=[]
        a.set_zorder(self.getp('zorder'))
        return a
开发者ID:piScope,项目名称:piScope,代码行数:25,代码来源:fig_circle.py

示例3: MplCircularROI

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_zorder [as 别名]
class MplCircularROI(AbstractMplRoi):

    """
    Class to display / edit circular ROIs using matplotlib

    Since circles on the screen may not be circles in the data
    (due, e.g., to logarithmic scalings on the axes), the
    ultimate ROI that is created is a polygonal ROI

    :param plot_opts:

               A dictionary of plot keywords that are passed to
               the patch representing the ROI. These control
               the visual properties of the ROI
    """

    def __init__(self, axes):
        """
        :param axes: A matplotlib Axes object to attach the graphical ROI to
        """

        AbstractMplRoi.__init__(self, axes)
        self.plot_opts = {'edgecolor': PATCH_COLOR, 'facecolor': PATCH_COLOR,
                          'alpha': 0.3}

        self._xi = None
        self._yi = None
        self._setup_patch()

    def _setup_patch(self):
        self._patch = Ellipse((0., 0.), transform=IdentityTransform(),
                              width=0., height=0.,)
        self._patch.set_zorder(100)
        self._patch.set(**self.plot_opts)
        self._axes.add_patch(self._patch)
        self._patch.set_visible(False)
        self._sync_patch()

    def _roi_factory(self):
        return CircularROI()

    def _sync_patch(self):
        # Update geometry
        if not self._roi.defined():
            self._patch.set_visible(False)
        else:
            xy = self._roi.get_center()
            r = self._roi.get_radius()
            self._patch.center = xy
            self._patch.width = 2. * r
            self._patch.height = 2. * r
            self._patch.set_visible(True)

        # Update appearance
        self._patch.set(**self.plot_opts)

        # Refresh
        self._axes.figure.canvas.draw()

    def start_selection(self, event):

        if event.inaxes != self._axes:
            return False

        xy = data_to_pixel(self._axes, [event.xdata], [event.ydata])
        xi = xy[0, 0]
        yi = xy[0, 1]

        if event.key == SCRUBBING_KEY:
            if not self._roi.defined():
                return False
            elif not self._roi.contains(xi, yi):
                return False

        self._roi_store()

        if event.key == SCRUBBING_KEY:
            self._scrubbing = True
            (xc, yc) = self._roi.get_center()
            self._dx = xc - xi
            self._dy = yc - yi
        else:
            self.reset()
            self._roi.set_center(xi, yi)
            self._roi.set_radius(0.)
            self._xi = xi
            self._yi = yi

        self._mid_selection = True
        self._sync_patch()

    def update_selection(self, event):

        if not self._mid_selection or event.inaxes != self._axes:
            return False

        xy = data_to_pixel(self._axes, [event.xdata], [event.ydata])
        xi = xy[0, 0]
        yi = xy[0, 1]

#.........这里部分代码省略.........
开发者ID:saimn,项目名称:glue,代码行数:103,代码来源:roi.py

示例4: __call__

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_zorder [as 别名]
        def __call__(self, inferrer, f_, curve_xs_, true_ys_, scatter_xs_, scatter_ys_, circles_, user_prefix_):

            # Some of this is hackish
            aux = [map(getNumber, p.getArray()) for p in fromStackDict(f_[0]["aux"]).getArray()]
            f = f_[0]["value"]

            prior_mean = f.mean
            prior_cov = f.covariance

            if len(aux) > 0:
                Xseen, Yseen = zip(*aux)
            else:
                Xseen, Yseen = [], []

            curve_xs = map(getNumber, fromStackDict(curve_xs_[0]).getArray())
            true_ys = map(getNumber, fromStackDict(true_ys_[0]).getArray())

            user_prefix = fromStackDict(user_prefix_[0]).getString()

            scatter_xs = map(getNumber, fromStackDict(scatter_xs_[0]).getArray())
            scatter_ys = map(getNumber, fromStackDict(scatter_ys_[0]).getArray())

            circles = map(lambda a: map(getNumber, a), map(getArray, fromStackDict(circles_[0]).getArray()))

            mean, cov = gp_conditional.conditional_mean_and_cov(curve_xs, prior_mean, prior_cov, Xseen, Yseen)

            fig, ax = plt.subplots(1)
            ax.set_xlabel("a")
            ax.set_ylabel("r(a)").set_rotation(0)
            ax.scatter(scatter_xs, scatter_ys, color="k", s=15)
            ax.set_xlim(min(curve_xs), max(curve_xs))
            for i in range(100):
                ys = np.random.multivariate_normal(mean, cov)
                ax.plot(curve_xs, ys, c="red", alpha=0.2, linewidth=2)
            if len(true_ys) > 0:
                ax.plot(curve_xs, true_ys, c="blue")
            for ccoords in circles:
                (x, y) = ccoords[0:2]

                def to_hex_color(n):
                    h = hex(int(n))[2:]
                    padded = (6 - len(h)) * "0" + h
                    return clr.hex2color("#" + padded)

                color = to_hex_color(ccoords[2]) if len(ccoords) > 2 else "green"
                xsize, ysize = ccoords[3:5] if len(ccoords) > 3 else (0.4, 0.33)
                circle = Ellipse([x, y], xsize, ysize, color=color, linewidth=5, fill=False)
                circle.set_zorder(10)
                ax.add_artist(circle)

            date_fmt = "%Y%m%d_%H%M%S"
            directory = "draw_gp_curves_callback"

            def j(fname):
                return os.path.join(directory, fname)

            output_prefix = "%s_%s" % (user_prefix, datetime.now().strftime(date_fmt))

            scatterpath = j("%s_scatter.pkl" % (output_prefix,))
            print "Logging scatter data to %s" % (scatterpath,)
            scatter_data = {"scatter_xs": scatter_xs, "scatter_ys": scatter_ys}
            with open(scatterpath, "wb") as f:
                pickle.dump(scatter_data, f)

            print "Outputting to %s.png" % (j(output_prefix),)
            fig.savefig("%s.png" % (j(output_prefix),), dpi=fig.dpi, bbox_inches="tight")
            print "Done."
开发者ID:bzinberg,项目名称:meng_thesis,代码行数:69,代码来源:draw_gp_curves_plugin.py

示例5: plotDensityMatricesContour

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_zorder [as 别名]
def plotDensityMatricesContour(densityMatrices,figureName = None,export=None,figureTitle = None,annotate = True,labels = [],show = "all"):
	from numpy import angle
	from pyview.ide.mpl.backend_agg import figure
	if figureName != None:
		fig = figure(figureName)
	from matplotlib.patches import Ellipse
	import matplotlib.cm
	
	NUM = 250

	#cmap = get_cmap('jet')

	sat = 0.8

	cdict = {'blue': ((0.0, sat, sat),(0.5, 1-sat, 1-sat),(1.0, sat, sat)),'green': ((0.0, 0,0),(0.5, 0,0),(1.0, 0,0)),'red': ((0.0, 1-sat, 1-sat),(0.5,sat,sat),(1,1-sat,1-sat))}
	my_cmap = matplotlib.colors.LinearSegmentedColormap('my_colormap',cdict,256)
	cmap = my_cmap

	if figureName != None:
		clf()
		cla()

	if figureTitle != None:
		title(figureTitle)
	
	n = densityMatrices[0].shape[0]

	ax = gca()
	ax.set_aspect('equal')	
	
	styles = ["solid","solid"]
	widths = [0.5,1]
	colors = ["black",'red',"blue","magenta","green"]
	
	for i in range(0,n):
		if show == "lowerTriangular":
			ax.add_artist(Line2D([-1,n-i-0.5],[0.5+i,0.5+i],ls = '--',color = 'grey'))	
			ax.add_artist(Line2D([0.5+i,0.5+i],[-1,n-i-0.5],ls = '--',color = 'grey'))
		elif show == "upperTriangular":
			ax.add_artist(Line2D([-1,n],[0.5+i,0.5+i],ls = '--',color = 'grey'))	
			ax.add_artist(Line2D([0.5+i,0.5+i],[-1,n],ls = '--',color = 'grey'))
		else:
			ax.add_artist(Line2D([-1,n],[0.5+i,0.5+i],ls = '--',color = 'grey'))	
			ax.add_artist(Line2D([0.5+i,0.5+i],[-1,n],ls = '--',color = 'grey'))
		for j in range(0,n):
			
			if show == "lowerTriangular":
				if j > n-i:
					continue
			elif show == "upperTriangular":
				if j < i:
					continue
			
			if i == n-j-1:
				rect = Rectangle(xy = [i-0.5,j-0.5],width = 1.0,height = 1.0)
				rect.set_facecolor([0.9,0.9,0.9])
				ax.add_artist(rect)
	
			plotted = False
			
			k = 0
	
			for densityMatrix in densityMatrices:
	
				v = abs(densityMatrix[n-j-1,i])
				r = sqrt(v)*0.9
				phi = angle(densityMatrix[n-j-1,i])
		
				e = Ellipse(xy=(i,j), width=r, height=r, angle=0,ls = styles[k%len(styles)],lw = widths[k%len(widths)])
			
				fc = cmap((phi+math.pi)/2.0/math.pi)
				
				t = Text(x = i+0.5-0.04,va = 'top',ha = 'right',y = j+0.5-0.04,text = "%.2f" % v,size = 'medium' )
				a = Arrow(x = i-0.45*r*cos(phi)*0,y = j-0.45*r*sin(phi)*0,dx = r*cos(phi)*0.5,dy = r*sin(phi)*0.5,zorder = 10,width = 0.1,fc = colors[k%len(colors)],lw = 0)
		
				e.set_clip_box(ax.bbox)
				e.set_alpha(1.0)
				e.set_facecolor('none')
				e.set_edgecolor(colors[k%len(colors)])
		
				if v > 0.01:
					ax.add_artist(a)
					ax.add_artist(e)
					plotted = True
					
				k+=1

			if plotted:
				e2 	= Ellipse(xy=(i,j), width=0.025, height=0.025, angle=0)
				e2.set_facecolor('black')
				e2.set_zorder(n*n*10)
				ax.add_artist(e2)
				

	if annotate and labels != []:
		yticks(arange(n-1,-1,-1),labels,rotation = -45)
		xticks(arange(0,n,1),labels,rotation = -45)
	else:
		yticks([0,1,2,3],["","","",""])
		xticks([0,1,2,3],["","","",""])
#.........这里部分代码省略.........
开发者ID:adewes,项目名称:python-qubit-setup,代码行数:103,代码来源:plot_density_matrix.py


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