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


Python Ellipse.set_color方法代码示例

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


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

示例1: plot_qudratic_confidence_region_2D_ellipsoid

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def plot_qudratic_confidence_region_2D_ellipsoid( \
    config, center, ellipsoid, no_grid, rows, cols, fig):
    subell = ellipsoid[numpy.ix_([rows,cols],[rows,cols])]
    eigenvals, eigenvecs = numpy.linalg.eig(subell)
    # sign eigenvals
    lambdaa = numpy.sqrt(eigenvals)

    plot_no = no_grid*cols+rows+1
    ax = fig.add_subplot(no_grid, no_grid, plot_no)
    ell = Ellipse(xy     = [center[rows],center[cols]], \
                  width  = lambdaa[0]*2, \
                  height = lambdaa[1]*2, \
                  angle  = numpy.rad2deg(numpy.arccos(eigenvecs[0,0])))
    ax.add_artist(ell)
    ell.set_clip_box(ax.bbox)
    
    sf = 1.0
    height = numpy.sqrt(subell[0,0]) * sf
    width = numpy.sqrt(subell[1,1]) * sf
    ax.set_xlim(center[rows]-height, center[rows]+height)
    ax.set_ylim(center[cols]-width, center[cols]+width)
    squared = True
    if squared:
        x0,x1 = ax.get_xlim()
        y0,y1 = ax.get_ylim()
        ax.set_aspect(abs(x1-x0)/abs(y1-y0))
    ax.plot([0],[0], 'b+')
    ell.set_color('b')
    ell.set_facecolor('none')
    ax.set_xticks(config.axes[cols].get_major_ticks())
    ax.set_yticks(config.axes[rows].get_major_ticks())
    handle_axes_labels(config, ax, rows, cols)
开发者ID:parolandi,项目名称:resproj,代码行数:34,代码来源:plots_regions.py

示例2: make_video

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def make_video(board):
	try:
		os.mkdir("plots1/%s"%board)
	except:
		pass
	table = astropy.table.Table.read("./export.fits")
	teams = TeamColorsIndices()
	rows_by_day = collections.defaultdict(list)
	for i,row in enumerate(table):
		d = parse_filename_date(row['filename']).date()
		if i==0:
			start_day = d
		day_count = (d-start_day).days
		rows_by_day[day_count].append(row)
	best_by_team = {}
	team_colors = TeamColorsIndices()
	count = 0
	for d in xrange(day_count+1):
		for row in rows_by_day[d]:
			if row['board']!=board+'-post': continue
			team = row['team']
			score = row['score']
			if team not in best_by_team or score>best_by_team[team]['score']:
				best_by_team[team] = row
				count += 1
				#print team, float(best_by_team[team]['score'])
		pylab.figure()
		ax = pylab.gca()
		for team,row in best_by_team.items():
			color,_ = team_colors(team)
			mp = row['m_plus']
			mm = row['m_cross']
			dmp = row['delta_m_plus']
			dmm = row['delta_m_cross']

			ell = Ellipse((mp,mm), width=dmp, height=dmm)
			ell.set_color(color)
			ell.set_alpha(0.2)
			ax.add_artist(ell)
		ax.set_xlim(-8e-2, 8e-2)
		ax.set_ylim(-8e-2, 8e-2)
		pylab.savefig("plots1/%s/%.5d.png"%(board,d))
		pylab.close()
	print 
	print "COUNT = ", count
	print
	cmd = "ffmpeg -pattern_type glob -i 'plots1/%s/*.png' plots1/%s.mp4" % (board, board)
	print cmd
	os.system(cmd)
开发者ID:barnabytprowe,项目名称:great3-public,代码行数:51,代码来源:ellipse_videos.py

示例3: plot_error_ellipses

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def plot_error_ellipses(ax, gmm, colors=None):
    """Plot error ellipses of GMM components.

    Parameters
    ----------
    ax : axis
        Matplotlib axis.

    gmm : GMM
        Gaussian mixture model.
    """
    from matplotlib.patches import Ellipse
    for factor in np.linspace(0.25, 2.0, 8):
        for i, (mean, (angle, width, height)) in enumerate(gmm.to_ellipses(factor)):
            ell = Ellipse(xy=mean, width=width, height=height,
                        angle=np.degrees(angle))
            ell.set_alpha(0.25)
            if colors and i < len(colors):
                ell.set_color(colors[i])
            ax.add_artist(ell)
开发者ID:HRZaheri,项目名称:gmr,代码行数:22,代码来源:gmm.py

示例4: plot_ellipses

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
    def plot_ellipses(self, X=None, ax=None, colors=['r', 'g', 'b', 'c', 'm'], ellipses_shapes=np.linspace(0.3, 2.0, 8)):
        """Plot error ellipses of GMM.

        Parameters
        ----------
        X : array of shape (n_samples, n_dimensions)
            MUST be 2 dimensions or None (TODO: generalize to many dimensions)

        ax : axis
            Matplotlib axis.

        colors : list
            list of colors

        ellipses_shapes : vector
            vector of ellipses factors shapes
        """
        X = X if X is not None else self.X_
        Y = self.predict(X)

        if colors is not None:
            colors = cycle(colors)

        if ax is None:
            fig = plt.figure(figsize=(15, 5))
            ax = fig.add_subplot(111)

        for factor in ellipses_shapes:
            for i, (mean, width, height, angle) in enumerate(self.to_ellipses(factor)):
                if X is not None:
                    if not np.any(Y == i):
                        continue
                color = next(colors) if colors is not None else 'r'
                if X is not None:
                    plt.scatter(X[Y == i, 0], X[Y == i, 1], .8, color=color)
                ell = Ellipse(xy=mean, width=width, height=height,
                              angle=np.degrees(angle))
                ell.set_alpha(0.25)
                ell.set_color(color)
                ax.add_artist(ell)
        return ax
开发者ID:show0k,项目名称:gmm-lbd,代码行数:43,代码来源:gmm.py

示例5: visualise_gmm_marg_2D_density

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def visualise_gmm_marg_2D_density(gmm,marg_index,ax=None,
                                  min_factor=.5,max_factor=3,steps=5, colors=["g"]):
    ax=get_ax(ax)
    ax.set_aspect(1)
    from matplotlib.patches import Ellipse
    from itertools import cycle
    if colors is not None:
        colors = cycle(colors)
    min_alpha=0.03
    max_alpha=0.4
    ax_range=[]
    gmm=gmm.marginalise(marg_index)
    for factor in np.linspace(min_factor, max_factor, steps):
        for (mean, (angle, width, height)),weight in zip(gmm.gmm_gmr.to_ellipses(factor),gmm.weights_):
            ell = Ellipse(xy=mean, width=width, height=height,
                          angle=np.degrees(angle))
            max_size=max(width,height)
            ax_range.append(((mean[0]-max_size,mean[0]+max_size),(mean[1]-max_size,mean[1]+max_size)))
            ell.set_alpha(min_alpha+(max_alpha-min_alpha)*weight)
            if colors is not None:
                ell.set_color(next(colors))
            ax.add_artist(ell)
开发者ID:MetaDev,项目名称:thesis-hypergenerator,代码行数:24,代码来源:visualisation.py

示例6: plot_error_ellipses

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def plot_error_ellipses(ax, gmm, colors=None):
    """Plot error ellipses of GMM components.

    Parameters
    ----------
    ax : axis
        Matplotlib axis.

    gmm : GMM
        Gaussian mixture model.
    """
    from matplotlib.patches import Ellipse
    from itertools import cycle
    if colors is not None:
        colors = cycle(colors)
    for factor in np.linspace(0.5, 4.0, 8):
        for mean, (angle, width, height) in gmm.to_ellipses(factor):
            ell = Ellipse(xy=mean, width=width, height=height,
                          angle=np.degrees(angle))
            ell.set_alpha(0.25)
            if colors is not None:
                ell.set_color(next(colors))
            ax.add_artist(ell)
开发者ID:ZhangAustin,项目名称:gmr,代码行数:25,代码来源:gmm.py

示例7: Ellipse

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
    # for GMM
    # covar = clf.covars_[i][0:2, 0:2]

    # for all modes of GMM
    covar = clf._get_covars()[i][0:2, 0:2]

    v, w, = linalg.eigh(covar)
    angle = np.arctan2(w[0][1], w[0][0]) * 180.0 / np.pi
    angle_out[i] = angle

    ell = Ellipse(means, v[0], v[1], angle)
    ax.add_artist(ell)
    ell.set_clip_box(ax.bbox)
    ell.set_facecolor('None')
    ell.set_fill(False)
    ell.set_color(color_iter.next())
    # ell.set_alpha(.25)

plt.xlim((np.min(tmid), np.max(tmid)))
plt.ylim((0,360))
plt.scatter(xo, yo, c='k', s=(zo / np.nanmax(r1)*20.)**2., alpha=0.6)
plt.show()

plt.figure()
h = plt.hist(angle_out)
plt.show()




plt.figure()
开发者ID:bmorris3,项目名称:stsp_contrib,代码行数:33,代码来源:gmm_test.py

示例8: main

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def main():
    #plotting limits
    limit_x = -6
    limit_y = 12

    #create meshgrid for plotting function
    x = np.linspace(limit_x, limit_y, 50)
    y = np.linspace(limit_x, limit_y, 50)
    X, Y = np.meshgrid(x, y)

    #values from assignment
    sigma_x = 3.5
    sigma_y = 1.5
    mean_x = 4
    mean_y = 2
    mean = [mean_x, mean_y]
    covariance = 4.2
    #build covariance matrix
    covariance_matrix = np.array([[sigma_x**2, covariance],[covariance, sigma_y**2]])
    #get distribution
    Z = normal(X, Y, mean, covariance_matrix)

    fig, top = plt.subplots(nrows=1, ncols=1)
    top.pcolormesh(X, Y, Z, shading='gouraud')

    #diagonlize covariance matrix
    (v_x,v_y),  v = np.linalg.eig(covariance_matrix)

    #components of first eigenvector
    angle = np.arctan(v[1,0]/v[0,0])
    print("Winkel zur x-Achse: ", np.rad2deg(angle))

    #eigen values are the sigmas
    width = np.sqrt(v_x)*2
    length = np.sqrt(v_y)*2

    print("Ellipsen größen width, length: ", width, length)
    e = Ellipse(xy=(mean_x, mean_y), width=width, height=length, angle= np.rad2deg(angle))
    e.set_color("white")
    e.set_alpha(0.7)
    top.add_artist(e)


    length_x = 0.5*width*np.cos(angle)
    y_2 = mean_y + np.tan(angle)*length_x
    x_2 = mean_x +length_x
    top.plot([mean_x, x_2],[mean_y, y_2] , color='white', linewidth=2)



    angle = np.pi/2 + angle
    length_x = 0.5*length*np.cos(angle)
    y_2 = mean_y + np.tan(angle)*length_x
    x_2 = mean_x + length_x
    top.plot([mean_x, x_2],[mean_y, y_2] , color='white', linewidth=2)



    #draw points
    top.errorbar([mean_x], [mean_y], xerr=sigma_x, yerr=sigma_y, linestyle='o', color="white", ecolor='white')
    top.text(mean_x + 1.5, mean_y - 1.5, r'$(\mu_x + \sigma_y, \mu_y + \sigma_y)$', fontsize=12, color="white")
    plt.title("2D- Gaußverteilung")
    plt.show()
开发者ID:mackaiver,项目名称:smd,代码行数:65,代码来源:aufgabe_1.py

示例9: drawPlan

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
def drawPlan(plan):

  from matplotlib.pyplot import figure, show
  from matplotlib.patches import Ellipse
  import numpy as np

  if 1:
    fig = figure(1,figsize=(8,5))
    fig.clf()

    ax = fig.add_subplot(111, autoscale_on=False, xlim=(-4,4), ylim=(-3,3))
    ax.plot([3, 3, -3, -3,3],[-2,2,2,-2,-2], 'r')

    els = [[-1,2],[3,0],[-1,-2]]
    r = 0.25
    for el in els:
      e = Ellipse((el[0], el[1]), r, r)
      e.set_color('g')
      r *= 1.5
      ax.add_patch(e)
    # TODO implement the radius properly

    # TODO plot an eclipse at the start (green)
    # plot ellipse at the end (red) # stop

    bx = fig.add_subplot(111, autoscale_on=False, xlim=(-4,4), ylim=(-3,3))
    #bx.scatter([.1,.1],[.2,.4])

    #x = 1
    #y = 2
    #dx = 0.5
    #dy = 0.5
    #bx.arrow(x, y, dx, dy, head_width=0.1, head_length=0.1)
    cur = plan[0]
    bx.scatter(cur.x,cur.y,c='g')
    for i in range(len(plan)-1):

      # current angle
      angle = turns(cur,plan[i+1],cur.a)[0] + cur.a
      # normalize the angle
      if angle < -pi:
        angle+=2*pi
      if angle > pi:
        angle-=2*pi
      print angle


      # we go in a 'reverse' direction

      #plot the two points
      x = cur.x
      y = cur.y
      dx = plan[i+1].x-x
      dy = plan[i+1].y-y

      dx -= cos(atan2(dy,dx))*0.2
      dy -= sin(atan2(dy,dx))*0.2
      
      
      print str(angle)+"ANGLE"
      if (angle < 0 and cur.y < plan[i+1].y) or \
          (angle == 0 and cur.x > plan[i+1].y) or \
          (angle > 0 and cur.y > plan[i+1].y):
        print "REVERSE"
        bx.arrow( plan[i+1].x,plan[i+1].y, -dx, -dy, head_width=0.1, head_length=0.1)
      else:
        print "NORMAL"
        bx.arrow(x, y, dx, dy, head_width=0.1, head_length=0.1)
      bx.scatter(cur.x,cur.y)

      cur = plan[i+1]
      cur.a = angle
    bx.scatter(cur.x,cur.y,c='r')

  show()
开发者ID:chid,项目名称:RSANavigationSystem,代码行数:77,代码来源:read.py

示例10: figure

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [as 别名]
if 1:
    fig = figure(1,figsize=(8,5))
    fig.clf()
    
   # bx = fig.add_subplot(111, autoscale_on=False, xlim=(-3,3), ylim=(-2,2))
   # bx.plot([3, 3, -3, -3],[-3,3,-3,3])

    ax = fig.add_subplot(111, autoscale_on=False, xlim=(-4,4), ylim=(-3,3))
    ax.plot([3, 3, -3, -3,3],[-2,2,2,-2,-2], 'r')

    els = [[-1,2],[3,0],[-1,-2]]
    r = 0.25
    for el in els:
      e = Ellipse((el[0], el[1]), r, r)
      e.set_color('g')
      r *= 1.5
      ax.add_patch(e)
    # TODO implement the radius properly
    
    bx = fig.add_subplot(111, autoscale_on=False, xlim=(-4,4), ylim=(-3,3))
    bx.scatter([.1,.1],[.2,.4])
    bx.scatter([.2,.2],[.2,.4])
    
    """
    ax.annotate('$->$', xy=(2., -1),  xycoords='data',
                xytext=(-150, -140), textcoords='offset points',
                bbox=dict(boxstyle="round", fc="0.8"),
                arrowprops=dict(arrowstyle="->",
                                patchB=el,
                                connectionstyle="angle,angleA=90,angleB=0,rad=10"),
开发者ID:chid,项目名称:RSANavigationSystem,代码行数:32,代码来源:charley.py

示例11: ROIellipse

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_color [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)
开发者ID:JoshBradshaw,项目名称:bloodtools,代码行数:84,代码来源:ROI.py


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