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


Python Circle.set_zorder方法代码示例

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


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

示例1: add_breadcrumb

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_zorder [as 别名]
 def add_breadcrumb(self):
     """ Adds a breadcrumb """
     c = Circle(self._loc, radius = 16.25)
     c.set_facecolor('0.65')  # grey
     c.set_edgecolor('black')
     c.set_zorder(zorders['breadcrumbs'])
     c.set_fill(True)
     self.view.add_artist(c)
     self.breadcrumbs.append(c)
     self.draw()
开发者ID:dwtj,项目名称:mars-rover,代码行数:12,代码来源:rover.py

示例2: add_danger

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_zorder [as 别名]
    def add_danger(self, danger_id):
        """ Appends a new danger to the appropriate list of `env`, and updates
        the `env` view. The position at which the danger is placed is computed
        based on the rover's location and direction, but also where on the
        robot that particular danger-detection sensor is located. """
        
        """if danger_id == left_bumper:
            
        elif danger_id == right_bumper:
            
        elif danger_id == left_and_right_bumper:

        elif danger_id == front_left_cliff:

        elif danger_id == front_right_cliff:

        elif danger_id == left_cliff:

        elif danger_id == right_cliff:

        elif danger_id == white_tape_front_left:

        elif danger_id == white_tape_front_right:

        elif danger_id == white_tape_left:

        elif danger_id == white_tape_right:

        elif danger_id == left_wheel:

        elif danger_id == right_wheel:

        elif danger_id == middle_wheel:

        else:
            raise NotImplementedError()
        """


        # Find the danger location using `danger_angle` and `danger_distance`
        # TODO: maybe later
        # danger_loc = conv_radial(self, danger_theta, danger_r)

        # Plot
        if (1 <= danger_id <= 3): # Bumper range in OIStopID
            """ Adds a bump """
            c = Circle(self._loc, radius = 6.25)
            c.set_facecolor('0.65')  # grey
            c.set_edgecolor('black')
            c.set_zorder(zorders['bumps'])
            c.set_fill(True)
            self.view.add_artist(c)
            self.bumps.append(c)
            self.draw()
        elif (4 <= danger_id <= 7): # Cliff range in OIStopID
            """ Adds a cliff """
            c = Circle(self._loc, radius = 6.25)
            c.set_facecolor('0.65')  # grey
            c.set_edgecolor('black')
            c.set_zorder(zorders['cliffs'])
            c.set_fill(True)
            self.view.add_artist(c)
            self.cliffs.append(c)
            self.draw()
        elif (12 <= danger_id <= 14): # Drop range in OIStopID
            """ Adds a drop """
            c = Circle(self._loc, radius = 6.25)
            c.set_facecolor('0.65')  # grey
            c.set_edgecolor('black')
            c.set_zorder(zorders['drops'])
            c.set_fill(True)
            self.view.add_artist(c)
            self.drops.append(c)
            self.draw()
        elif (8 <= danger_id <= 11): # White tape range in OIStopID
            """ Adds tape """
            c = Circle(self._loc, radius = 6.25)
            c.set_facecolor('0.65')  # grey
            c.set_edgecolor('black')
            c.set_zorder(zorders['tape'])
            c.set_fill(True)
            self.view.add_artist(c)
            self.tape.append(c)
            self.draw()
        else:
            raise NotImplementedError()
            
        # The following is the temporary workaround:
        sys.stderr.write("danger found: " + str(danger_id)) # TODO: check to see if enum strig is a thing
开发者ID:dwtj,项目名称:mars-rover,代码行数:91,代码来源:rover.py

示例3: draw_network

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_zorder [as 别名]
def draw_network(G, pos, node_color=None, ax=None,
                 radius=1.4, node_alpha=0.5, edge_alpha=0.25,
                 fontsize=12, only_nodes = None):
    """Improved drawing of directed graphs in NetworkX.

    Modified from http://groups.google.com/group/networkx-discuss/
    browse_thread/thread/170624d22c4b0ee6?pli=1.

    Author of original: Stefan van der Walt

    Parameters
    ----------
    pos : dictionary
      A dictionary with nodes as keys and positions as values.

    node_color : string or array of floats
      A single color format string, or a sequence of colors with an entry
      for each node in G.
    """
    if ax is None:
        f, ax = plt.subplots()

    if only_nodes is None:
        only_nodes = set(G.nodes())
        

    only_nodes = set(only_nodes) if not isinstance(only_nodes, set) else \
                 only_nodes

    # Find the set of all the nodes connected to the ones we want to highlight
    connected = set()
    for n in only_nodes:
        connected.update(G.predecessors(n) + G.successors(n))

    # Walk and draw nodes
    for i, n in enumerate(G.nodes()):
        if node_color is None:
            color = (0, 0, 0)
        else:
            color = node_color[n]
        #if node_color is None or cmap is None:
        #    color = (0,0,0)
        #else:
        #    color = cmap(node_color[n])

        # Selectively de-highlight nodes not being shown
        if n in only_nodes:
            t_alpha = 1.0
            n_alpha = node_alpha
            zorder = 2.2
        elif n in connected:
            t_alpha = n_alpha = 0.6*node_alpha
            zorder = 2.0
        else:
            t_alpha = n_alpha = 0.15*node_alpha
            zorder = 1.8

        c = Circle(pos[n],radius=radius,
                   alpha=n_alpha,
                   color=color,ec='k')
        x, y = pos[n]
        t = plt.text(x, y, n, horizontalalignment='center',
                     verticalalignment='center', color='k', fontsize=fontsize,
                     weight='bold', alpha=t_alpha)
        t.set_zorder(zorder+0.1)
        c = ax.add_patch(c)
        c.set_zorder(zorder)
        G.node[n]['patch']=c
        x,y=pos[n]

    # Walk and draw edges. Keep track of edges already seen to offset
    # multiedges and merge u<->v edges into one.
    
    seen={}
    for (u,v) in G.edges(data=False):
        if not (u in only_nodes or v in only_nodes):
            continue
        
        n1 = G.node[u]['patch']
        n2 = G.node[v]['patch']
        rad=0.1
        color = 'k'
    
        if (u,v) in seen:
            # For multiedges, offset new ones
            rad=seen.get((u,v))
            rad=(rad + np.sign(rad)*0.1)*-1

        # If the opposite edge had already been drawn, draw on the same line to
        # reduce clutter.
        if (v,u) in seen:
            arrowstyle = '<|-'
            c1, c2, pA, pB = n2.center, n1.center, n2, n1
        else:
            arrowstyle = '-|>'
            c1, c2, pA, pB = n1.center, n2.center, n1, n2
            
        e = FancyArrowPatch(c1, c2, patchA=pA, patchB=pB,
                            arrowstyle=arrowstyle,
                            connectionstyle='arc3,rad=%s'%rad,
#.........这里部分代码省略.........
开发者ID:MSenden,项目名称:CoCoTools,代码行数:103,代码来源:nxdraw.py


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