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


Python Circle.set_color方法代码示例

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


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

示例1: __init__

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_color [as 别名]
    def __init__(self, axes, sim, type_to_radius, type_to_color):
        assert len(type_to_radius) == len(type_to_color)

        particle_types_arr = sim.types
        self._typeToRadius = type_to_radius
        self._typeToColor = type_to_color
        self._particleCircles = []
        self._sim = sim
        for particleType in particle_types_arr:
            c = Circle((0, 0, 0), type_to_radius[particleType], )
            c.set_color(self._typeToColor[particleType])
            self._particleCircles.append(c)
            axes.add_patch(c)

        axes.set_xlim([0, sim.domain_size[0]])
        axes.set_ylim([0, sim.domain_size[1]])
        axes.set_aspect('equal')
开发者ID:mabau,项目名称:statistical_mechanics_teaching,代码行数:19,代码来源:mpl_display.py

示例2: draw_ink

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_color [as 别名]
def draw_ink(ax, ink, node_size=0.1, penup_color='#0000FF',
             pendown_color='#00FF00', node_colors=None,
             show_order=False):
    current_stroke_id = 0
    for i in range(ink.shape[0]):
        # skip pen-up
        if ink[i,4] > 0:
            continue
            
        e = Circle(xy=(ink[i,0],ink[i,1]),radius=node_size, alpha=0.5)
        ax.add_artist(e)
        
        # pen-up/pen-down
        if i == 0 or ink[i-1,4] > 0:
            e.set_color(pendown_color)
            e.set_linewidth(5.0)
            current_stroke_id += 1

            if show_order:
                ax.text(ink[i,0]+node_size,ink[i,1],"[%d]"%current_stroke_id)

        elif i == ink.shape[0]-1 or ink[i+1,4] > 0:
            e.set_color(penup_color)
            e.set_linewidth(5.0)
            
        if node_colors is not None:
            e.set_facecolor(node_colors[i])
        
        # draw arrow
        if (i < ink.shape[0]-1 and
            ink[i,4] < 1 and
            ink[i+1,4] < 1):
            dx = ink[i+1,0]-ink[i,0]
            dy = ink[i+1,1]-ink[i,1]
            z = np.sqrt(dx*dx+dy*dy)
            dx = dx / max(z,1e-5)
            dy = dy / max(z,1e-5)
            if abs(dx) > 0 or abs(dy) > 0:
                ax.arrow(ink[i,0]-0.5*node_size*dx,
                         ink[i,1]-0.5*node_size*dy,
                         node_size*dx, node_size*dy,
                         fc="k", ec="k", alpha=0.5, width=0.007,
                         head_width=0.03, head_length=0.02,
                         length_includes_head=True)            

    ax.axis('equal')
开发者ID:sunsern,项目名称:uright-python,代码行数:48,代码来源:visualization.py

示例3: SmithChart

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_color [as 别名]

#.........这里部分代码省略.........
        if event.button == 3:
            print 'clearing'
            self.fig.canvas.restore_region(self.background, bbox=self.ax.bbox)

    def _on_mouse_move(self, event):
        if event.xdata is None or event.ydata is None:
            return

        gamma = event.xdata + 1j*event.ydata
        cursor_port = OnePort(s=gamma)

        self.fig.canvas.restore_region(self.background, bbox=self.ax.bbox)

        self.update_gain_cursor(cursor_port)
        self.update_info_box(cursor_port)

        #self.fig.canvas.draw()
        self.fig.canvas.blit(self.ax.bbox)

    def update_gain_cursor(self, cursor_port):
        if not self.gain_cursor or self.two_port is None:
            return

        if self.current_plane == 'source':
            term_matched = (cursor_port*self.two_port).out().conj()
            term_resulting = (self.two_port*term_matched).inp()
        else:
            term_matched = (self.two_port*cursor_port).inp().conj()
            term_resulting = (term_matched*self.two_port).out()

        self.circle_matched_term.center = real(term_matched.s), imag(term_matched.s)

        if abs(term_matched.s) > 1 or abs(term_resulting.s) > 1:
            self.circle_matched_term.set_color('r')
        else:
            self.circle_matched_term.set_color('g')

        self.ax.draw_artist(self.circle_matched_term)

    def update_info_box(self, cursor_port):
        z = cursor_port.z
        y = cursor_port.y

        data = '$\\Gamma$ = {:>7.2f} $\\angle$ {:>+8.3f}$^{{\\circ}}$'.format(float(abs(cursor_port.s)), float(degrees(angle(cursor_port.s))))
        data += '\nVSWR = {:>7.2f}'.format(float(cursor_port.vswr()))
        data += '\nMM = {:>7.2f} dB'.format(float(db(cursor_port.mismatch())))
        data += '\nZ = {:>7.2f}{:>+8.2f}j '.format(float(real(z)), float(imag(z)))

        if self.two_port is not None:
            if self.current_plane == 'source':
                term_matched = (cursor_port*self.two_port).out().conj()
                gain = self.two_port.g_t(cursor_port, term_matched)
            else:
                term_matched = (self.two_port*cursor_port).inp().conj()
                gain = self.two_port.g_t(term_matched, cursor_port)

            x = float(imag(z))
            w = 2*pi*self.two_port.f[0]

            if x > 0:
                hf = 'H'
                lc = x/w
            else:
                hf = 'F'
                lc = 1/(w*x)
开发者ID:fuesika,项目名称:PyTwoPort,代码行数:69,代码来源:smithplot.py

示例4: Line2D

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_color [as 别名]
import matplotlib
from matplotlib.lines import Line2D
from matplotlib.patches import Circle
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlim((0,100))
ax.set_ylim((0,100))
l = Line2D(np.arange(0,100),np.arange(100,000,-1))
c = Circle((10,10),20)
ax.add_line(l)
ax.add_artist(c)
fig.show()

l.set_color("red")
c.set_color("red")
fig.canvas.draw()


开发者ID:BenjaminPeter,项目名称:pooGUI,代码行数:21,代码来源:test.py


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