當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。