Exemplo n.º 1
0
 def shot_arrow(loc0, loc1):
     import matplotlib.patches as patches
     style = patches.ArrowStyle('-|>', head_length=2, head_width=2)
     connection = patches.ConnectionStyle("Arc3", rad=0)
     arrow = patches.FancyArrowPatch(tuple(loc0), tuple(
         loc1), arrowstyle=style, connectionstyle=connection, linestyle='-', color='red', linewidth=2)
     return arrow
Exemplo n.º 2
0
 def carry_arrow(loc0, loc1):
     import matplotlib.patches as patches
     style = patches.ArrowStyle('-')
     connection = patches.ConnectionStyle("Arc3", rad=0)
     arrow = patches.FancyArrowPatch(tuple(loc0), tuple(
         loc1), arrowstyle=style, connectionstyle=connection, linestyle='--')
     return arrow
Exemplo n.º 3
0
 def pass_arrow(loc0, loc1):
     import matplotlib.patches as patches
     style = patches.ArrowStyle('->', head_length=5, head_width=5)
     connection = patches.ConnectionStyle("Arc3", rad=0)
     arrow = patches.FancyArrowPatch(tuple(loc0), tuple(
         loc1), arrowstyle=style, connectionstyle=connection, linestyle='-')
     return arrow
Exemplo n.º 4
0
def _draw_edges(ax: mpl.axes.Subplot, graph: nx.classes.Graph, pos,
                nodes: dict) -> dict:
    """Draw the edges of a (small) networkx graph.

    Args:
        ax:    Axis.
        graph: Networkx graph object.
        pos:   Positions computed by nx.layout methods.
        nodes: Circle patches.

    Returns:
        Dictionary of Circle patches.
    """
    pointer = patches.ArrowStyle.Fancy(head_width=10, head_length=15)
    curved_edge = patches.ConnectionStyle('arc3', rad=.2)

    arrow_kwargs = {
        'arrowstyle': pointer,
        'antialiased': True,
        'connectionstyle': curved_edge,
        'edgecolor': None,
        'facecolor': None,
        'linewidth': 1.
    }

    edges = {}
    for i, (a, b, attr) in enumerate(graph.edges.data()):
        arrow_kwargs['edgecolor'] = attr['color']
        arrow_kwargs['facecolor'] = attr['color']

        edge = patches.FancyArrowPatch(pos[a],
                                       pos[b],
                                       patchA=nodes[a],
                                       patchB=nodes[b],
                                       shrinkA=5,
                                       shrinkB=5,
                                       **arrow_kwargs)
        ax.add_patch(edge)
        edges[(a, b)] = edge
    return edges