Python matplotlib.patches.FancyArrowPatch() Examples
The following are 30
code examples of matplotlib.patches.FancyArrowPatch().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.patches
, or try the search function
.
Example #1
Source File: test_arrow_patches.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_fancyarrow_dash(): from matplotlib.patches import FancyArrowPatch fig, ax = plt.subplots() e = FancyArrowPatch((0, 0), (0.5, 0.5), arrowstyle='-|>', connectionstyle='angle3,angleA=0,angleB=90', mutation_scale=10.0, linewidth=2, linestyle='dashed', color='k') e2 = FancyArrowPatch((0, 0), (0.5, 0.5), arrowstyle='-|>', connectionstyle='angle3', mutation_scale=10.0, linewidth=2, linestyle='dotted', color='k') ax.add_patch(e) ax.add_patch(e2)
Example #2
Source File: text.py From ImageFusion with MIT License | 6 votes |
def update_bbox_position_size(self, renderer): """ Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. """ # For arrow_patch, use textbox as patchA by default. if not isinstance(self.arrow_patch, FancyArrowPatch): return if self._bbox_patch: posx, posy = self._x, self._y x_box, y_box, w_box, h_box = _get_textbox(self, renderer) self._bbox_patch.set_bounds(0., 0., w_box, h_box) theta = np.deg2rad(self.get_rotation()) tr = mtransforms.Affine2D().rotate(theta) tr = tr.translate(posx + x_box, posy + y_box) self._bbox_patch.set_transform(tr) fontsize_in_pixel = renderer.points_to_pixels(self.get_size()) self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
Example #3
Source File: test_arrow_patches.py From twitter-stock-recommendation with MIT License | 6 votes |
def __prepare_fancyarrow_dpi_cor_test(): """ Convenience function that prepares and returns a FancyArrowPatch. It aims at being used to test that the size of the arrow head does not depend on the DPI value of the exported picture. NB: this function *is not* a test in itself! """ fig2 = plt.figure("fancyarrow_dpi_cor_test", figsize=(4, 3), dpi=50) ax = fig2.add_subplot(111) ax.set_xlim([0, 1]) ax.set_ylim([0, 1]) ax.add_patch(mpatches.FancyArrowPatch(posA=(0.3, 0.4), posB=(0.8, 0.6), lw=3, arrowstyle=u'->', mutation_scale=100)) return fig2
Example #4
Source File: test_arrow_patches.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_fancyarrow_dash(): from matplotlib.patches import FancyArrowPatch fig, ax = plt.subplots() e = FancyArrowPatch((0, 0), (0.5, 0.5), arrowstyle='-|>', connectionstyle='angle3,angleA=0,angleB=90', mutation_scale=10.0, linewidth=2, linestyle='dashed', color='k') e2 = FancyArrowPatch((0, 0), (0.5, 0.5), arrowstyle='-|>', connectionstyle='angle3', mutation_scale=10.0, linewidth=2, linestyle='dotted', color='k') ax.add_patch(e) ax.add_patch(e2)
Example #5
Source File: text.py From Computable with MIT License | 6 votes |
def update_bbox_position_size(self, renderer): """ Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. """ # For arrow_patch, use textbox as patchA by default. if not isinstance(self.arrow_patch, FancyArrowPatch): return if self._bbox_patch: posx, posy = self._x, self._y x_box, y_box, w_box, h_box = _get_textbox(self, renderer) self._bbox_patch.set_bounds(0., 0., w_box, h_box) theta = np.deg2rad(self.get_rotation()) tr = mtransforms.Affine2D().rotate(theta) tr = tr.translate(posx + x_box, posy + y_box) self._bbox_patch.set_transform(tr) fontsize_in_pixel = renderer.points_to_pixels(self.get_size()) self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
Example #6
Source File: test_arrow_patches.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __prepare_fancyarrow_dpi_cor_test(): """ Convenience function that prepares and returns a FancyArrowPatch. It aims at being used to test that the size of the arrow head does not depend on the DPI value of the exported picture. NB: this function *is not* a test in itself! """ fig2 = plt.figure("fancyarrow_dpi_cor_test", figsize=(4, 3), dpi=50) ax = fig2.add_subplot(111) ax.set_xlim([0, 1]) ax.set_ylim([0, 1]) ax.add_patch(mpatches.FancyArrowPatch(posA=(0.3, 0.4), posB=(0.8, 0.6), lw=3, arrowstyle='->', mutation_scale=100)) return fig2
Example #7
Source File: text.py From matplotlib-4-abaqus with MIT License | 6 votes |
def update_bbox_position_size(self, renderer): """ Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. """ # For arrow_patch, use textbox as patchA by default. if not isinstance(self.arrow_patch, FancyArrowPatch): return if self._bbox_patch: posx, posy = self._x, self._y x_box, y_box, w_box, h_box = _get_textbox(self, renderer) self._bbox_patch.set_bounds(0., 0., w_box, h_box) theta = np.deg2rad(self.get_rotation()) tr = mtransforms.Affine2D().rotate(theta) tr = tr.translate(posx + x_box, posy + y_box) self._bbox_patch.set_transform(tr) fontsize_in_pixel = renderer.points_to_pixels(self.get_size()) self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
Example #8
Source File: state_graph.py From dynamo-release with BSD 3-Clause "New" or "Revised" License | 6 votes |
def create_edge_patch( posA, posB, width=1, node_rad=0, connectionstyle="arc3, rad=0.25", facecolor="k", **kwargs ): import matplotlib.patches as pat style = "simple,head_length=%d,head_width=%d,tail_width=%d" % (10, 10, 3 * width) return pat.FancyArrowPatch( posA=posA, posB=posB, arrowstyle=style, connectionstyle=connectionstyle, facecolor=facecolor, shrinkA=node_rad, shrinkB=node_rad, **kwargs )
Example #9
Source File: test_arrow_patches.py From coffeegrindsize with MIT License | 6 votes |
def test_fancyarrow_dash(): from matplotlib.patches import FancyArrowPatch fig, ax = plt.subplots() e = FancyArrowPatch((0, 0), (0.5, 0.5), arrowstyle='-|>', connectionstyle='angle3,angleA=0,angleB=90', mutation_scale=10.0, linewidth=2, linestyle='dashed', color='k') e2 = FancyArrowPatch((0, 0), (0.5, 0.5), arrowstyle='-|>', connectionstyle='angle3', mutation_scale=10.0, linewidth=2, linestyle='dotted', color='k') ax.add_patch(e) ax.add_patch(e2)
Example #10
Source File: test_arrow_patches.py From coffeegrindsize with MIT License | 6 votes |
def __prepare_fancyarrow_dpi_cor_test(): """ Convenience function that prepares and returns a FancyArrowPatch. It aims at being used to test that the size of the arrow head does not depend on the DPI value of the exported picture. NB: this function *is not* a test in itself! """ fig2 = plt.figure("fancyarrow_dpi_cor_test", figsize=(4, 3), dpi=50) ax = fig2.add_subplot(111) ax.set_xlim([0, 1]) ax.set_ylim([0, 1]) ax.add_patch(mpatches.FancyArrowPatch(posA=(0.3, 0.4), posB=(0.8, 0.6), lw=3, arrowstyle='->', mutation_scale=100)) return fig2
Example #11
Source File: text.py From neural-network-animation with MIT License | 6 votes |
def update_bbox_position_size(self, renderer): """ Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. """ # For arrow_patch, use textbox as patchA by default. if not isinstance(self.arrow_patch, FancyArrowPatch): return if self._bbox_patch: posx, posy = self._x, self._y x_box, y_box, w_box, h_box = _get_textbox(self, renderer) self._bbox_patch.set_bounds(0., 0., w_box, h_box) theta = np.deg2rad(self.get_rotation()) tr = mtransforms.Affine2D().rotate(theta) tr = tr.translate(posx + x_box, posy + y_box) self._bbox_patch.set_transform(tr) fontsize_in_pixel = renderer.points_to_pixels(self.get_size()) self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
Example #12
Source File: test_arrow_patches.py From coffeegrindsize with MIT License | 5 votes |
def test_arrow_styles(): styles = mpatches.ArrowStyle.get_styles() n = len(styles) fig, ax = plt.subplots(figsize=(6, 10)) ax.set_xlim(0, 1) ax.set_ylim(-1, n) for i, stylename in enumerate(sorted(styles)): patch = mpatches.FancyArrowPatch((0.1, i), (0.8, i), arrowstyle=stylename, mutation_scale=25) ax.add_patch(patch)
Example #13
Source File: tools.py From Motiftoolbox with GNU General Public License v2.0 | 5 votes |
def add_arrow(ax, tailhead, **kwargs): arrowDict = dict(linewidth=1., color='k', arrowstyle='-|>', mutation_scale=12 * 1) arrowDict.update(kwargs) p = patches.FancyArrowPatch(tailhead[0], tailhead[1], transform=ax.transData, **arrowDict) ax.add_patch(p)
Example #14
Source File: utils.py From dynamo-release with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_arrow_alpha(ax=None, alpha=1): from matplotlib import patches ax = plt.gca() if ax is None else ax # iterate through the children of ax for art in ax.get_children(): # we are only interested in FancyArrowPatches if not isinstance(art, patches.FancyArrowPatch): continue art.set_alpha(alpha)
Example #15
Source File: test_arrow_patches.py From coffeegrindsize with MIT License | 5 votes |
def test_fancyarrow_dpi_cor_100dpi(): """ Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is instantiated through a dedicated function because another similar test checks a similar export but with a different DPI value. Remark: test only a rasterized format. """ __prepare_fancyarrow_dpi_cor_test()
Example #16
Source File: test_arrow_patches.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_invalid_intersection(): conn_style_1 = mpatches.ConnectionStyle.Angle3(angleA=20, angleB=200) p1 = mpatches.FancyArrowPatch((.2, .2), (.5, .5), connectionstyle=conn_style_1) with pytest.raises(ValueError): plt.gca().add_patch(p1) conn_style_2 = mpatches.ConnectionStyle.Angle3(angleA=20, angleB=199.9) p2 = mpatches.FancyArrowPatch((.2, .2), (.5, .5), connectionstyle=conn_style_2) plt.gca().add_patch(p2)
Example #17
Source File: test_arrow_patches.py From coffeegrindsize with MIT License | 5 votes |
def test_invalid_intersection(): conn_style_1 = mpatches.ConnectionStyle.Angle3(angleA=20, angleB=200) p1 = mpatches.FancyArrowPatch((.2, .2), (.5, .5), connectionstyle=conn_style_1) with pytest.raises(ValueError): plt.gca().add_patch(p1) conn_style_2 = mpatches.ConnectionStyle.Angle3(angleA=20, angleB=199.9) p2 = mpatches.FancyArrowPatch((.2, .2), (.5, .5), connectionstyle=conn_style_2) plt.gca().add_patch(p2)
Example #18
Source File: vectorartist.py From compas with MIT License | 5 votes |
def draw(self): style = ArrowStyle("Simple, head_length=.1, head_width=.1, tail_width=.01") arrow = FancyArrowPatch(self.point[:2], (self.point + self.vector)[:2], arrowstyle=style, edgecolor=self.color, facecolor=self.color, zorder=self.zorder, mutation_scale=100) if self._draw_point: self.point_artist = self.plotter.add(self.point) self.mpl_vector = self.plotter.axes.add_patch(arrow)
Example #19
Source File: plotter.py From compas with MIT License | 5 votes |
def draw_arrows2(self, arrows): for data in arrows: a = data['start'][:2] b = data['end'][:2] color = data.get('color', (0.0, 0.0, 0.0)) style = ArrowStyle("Simple, head_length=.1, head_width=.1, tail_width=.02") arrow = FancyArrowPatch(a, b, arrowstyle=style, edgecolor=color, facecolor=color, zorder=2000, mutation_scale=100) self.axes.add_patch(arrow)
Example #20
Source File: test_arrow_patches.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_fancyarrow_dpi_cor_100dpi(): """ Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is instantiated through a dedicated function because another similar test checks a similar export but with a different DPI value. Remark: test only a rasterized format. """ __prepare_fancyarrow_dpi_cor_test()
Example #21
Source File: test_arrow_patches.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_arrow_styles(): styles = mpatches.ArrowStyle.get_styles() n = len(styles) fig, ax = plt.subplots(figsize=(6, 10)) ax.set_xlim(0, 1) ax.set_ylim(-1, n) for i, stylename in enumerate(sorted(styles)): patch = mpatches.FancyArrowPatch((0.1, i), (0.8, i), arrowstyle=stylename, mutation_scale=25) ax.add_patch(patch)
Example #22
Source File: vis_utils.py From nucleus7 with Mozilla Public License 2.0 | 5 votes |
def _draw_without_key_connections(dna_helix_graph, node_size_pixels, nucleotide_positions, subplot ) -> List[patches.FancyArrowPatch]: edge_patches = nx.draw_networkx_edges( dna_helix_graph, pos=nucleotide_positions, node_size=node_size_pixels, ax=subplot) return edge_patches
Example #23
Source File: vis_utils.py From nucleus7 with Mozilla Public License 2.0 | 5 votes |
def _draw_with_key_connections(dna_helix_graph, nucleotide_plots, subplot ) -> List[patches.FancyArrowPatch]: edge_patches = [] for each_nucleotide in dna_helix_graph: edge_patches_for_nucleotide = _draw_nucleotide_keys_connections( each_nucleotide, dna_helix_graph, nucleotide_plots) if edge_patches_for_nucleotide: edge_patches.extend(edge_patches_for_nucleotide) for each_edge_patch in edge_patches: subplot.add_patch(each_edge_patch) return edge_patches
Example #24
Source File: test_arrow_patches.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_arrow_styles(): styles = mpatches.ArrowStyle.get_styles() n = len(styles) fig, ax = plt.subplots(figsize=(6, 10)) ax.set_xlim(0, 1) ax.set_ylim(-1, n) for i, stylename in enumerate(sorted(styles)): patch = mpatches.FancyArrowPatch((0.1, i), (0.8, i), arrowstyle=stylename, mutation_scale=25) ax.add_patch(patch)
Example #25
Source File: test_arrow_patches.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_fancyarrow_dpi_cor_100dpi(): """ Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is instantiated through a dedicated function because another similar test checks a similar export but with a different DPI value. Remark: test only a rasterized format. """ __prepare_fancyarrow_dpi_cor_test()
Example #26
Source File: vis_utils.py From nucleus7 with Mozilla Public License 2.0 | 5 votes |
def _draw_nucleotide_keys_connections(nucleotide, dna_helix_graph, nucleotide_plots ) -> List[patches.FancyArrowPatch]: edge_patches_for_nucleotide = [] predecessors = dna_helix_graph.predecessors(nucleotide) successors = dna_helix_graph.successors(nucleotide) for each_inbound_nucleotide in predecessors: edge_patches = _draw_key_connections_for_nucleotide_pair( nucleotide, each_inbound_nucleotide, nucleotide_plots) edge_patches_for_nucleotide.extend(edge_patches) for each_outgoing_nucleotide in successors: edge_patches = _draw_key_connections_for_nucleotide_pair( each_outgoing_nucleotide, nucleotide, nucleotide_plots) edge_patches_for_nucleotide.extend(edge_patches) return edge_patches_for_nucleotide
Example #27
Source File: vis_utils.py From nucleus7 with Mozilla Public License 2.0 | 5 votes |
def _draw_key_connections_for_nucleotide_pair( nucleotide: Nucleotide, inbound_nucleotide: Nucleotide, nucleotide_plots: Dict[Nucleotide, _NUCLEOTIDE_PLOT] ) -> List[patches.FancyArrowPatch]: nucleotide_plot = nucleotide_plots[nucleotide] incoming_nucleotide_plot = nucleotide_plots[inbound_nucleotide] inputs_to_nucleotide = {each_inbound_node: {"": None} for each_inbound_node in nucleotide.inbound_nodes} inputs_to_nucleotide[inbound_nucleotide.name] = { k: k for k in inbound_nucleotide.generated_keys_all} inputs_to_nucleotide_filtered = nucleotide.filter_inputs( inputs_to_nucleotide) if "" in inputs_to_nucleotide_filtered: del inputs_to_nucleotide_filtered[""] edge_patches = [] for each_incoming_key, each_generated_key in ( inputs_to_nucleotide_filtered.items()): edge_patch = _draw_edge_between_keys( nucleotide, inbound_nucleotide, each_incoming_key, each_generated_key, nucleotide_plot, incoming_nucleotide_plot) edge_patches.append(edge_patch) return edge_patches
Example #28
Source File: snap.py From pylustrator with GNU General Public License v3.0 | 4 votes |
def set_positions(self, points: (int, int)): """ set the position of the target Artist """ points = self.transform_inverted_points(points) if isinstance(self.target, Rectangle): self.target.set_xy(points[0]) self.target.set_width(points[1][0] - points[0][0]) self.target.set_height(points[1][1] - points[0][1]) if self.target.get_label() is None or not self.target.get_label().startswith("_rect"): self.figure.change_tracker.addChange(self.target, ".set_xy([%f, %f])" % tuple(self.target.get_xy())) self.figure.change_tracker.addChange(self.target, ".set_width(%f)" % self.target.get_width()) self.figure.change_tracker.addChange(self.target, ".set_height(%f)" % self.target.get_height()) elif isinstance(self.target, Ellipse): self.target.center = np.mean(points, axis=0) self.target.width = points[1][0] - points[0][0] self.target.height = points[1][1] - points[0][1] self.figure.change_tracker.addChange(self.target, ".center = (%f, %f)" % tuple(self.target.center)) self.figure.change_tracker.addChange(self.target, ".width = %f" % self.target.width) self.figure.change_tracker.addChange(self.target, ".height = %f" % self.target.height) elif isinstance(self.target, FancyArrowPatch): self.target.set_positions(points[0], points[1]) self.figure.change_tracker.addChange(self.target, ".set_positions(%s, %s)" % (tuple(points[0]), tuple(points[1]))) elif isinstance(self.target, Text): if checkXLabel(self.target): axes = checkXLabel(self.target) axes.xaxis.labelpad = -(points[0][1] - self.target.pad_offset) / self.label_factor self.figure.change_tracker.addChange(axes, ".xaxis.labelpad = %f" % axes.xaxis.labelpad) self.target.set_position(points[0]) self.label_y = points[0][1] elif checkYLabel(self.target): axes = checkYLabel(self.target) axes.yaxis.labelpad = -(points[0][0] - self.target.pad_offset) / self.label_factor self.figure.change_tracker.addChange(axes, ".yaxis.labelpad = %f" % axes.yaxis.labelpad) self.target.set_position(points[0]) self.label_x = points[0][0] else: self.target.set_position(points[0]) self.figure.change_tracker.addChange(self.target, ".set_position([%f, %f])" % self.target.get_position()) if getattr(self.target, "xy", None) is not None: self.target.xy = points[1] self.figure.change_tracker.addChange(self.target, ".xy = (%f, %f)" % tuple(self.target.xy)) elif isinstance(self.target, Legend): point = self.target.axes.transAxes.inverted().transform(self.transform_inverted_points(points)[0]) self.target._loc = tuple(point) self.figure.change_tracker.addChange(self.target, "._set_loc((%f, %f))" % tuple(point)) elif isinstance(self.target, Axes): position = np.array([points[0], points[1] - points[0]]).flatten() if self.fixed_aspect: position[3] = position[2] * self.target.get_position().height / self.target.get_position().width self.target.set_position(position) self.figure.change_tracker.addChange(self.target, ".set_position([%f, %f, %f, %f])" % tuple( np.array([points[0], points[1] - points[0]]).flatten()))
Example #29
Source File: offsetbox.py From twitter-stock-recommendation with MIT License | 4 votes |
def _update_position_xybox(self, renderer, xy_pixel): """ Update the pixel positions of the annotation text and the arrow patch. """ x, y = self.xybox if isinstance(self.boxcoords, tuple): xcoord, ycoord = self.boxcoords x1, y1 = self._get_xy(renderer, x, y, xcoord) x2, y2 = self._get_xy(renderer, x, y, ycoord) ox0, oy0 = x1, y2 else: ox0, oy0 = self._get_xy(renderer, x, y, self.boxcoords) w, h, xd, yd = self.offsetbox.get_extent(renderer) _fw, _fh = self._box_alignment self.offsetbox.set_offset((ox0 - _fw * w + xd, oy0 - _fh * h + yd)) # update patch position bbox = self.offsetbox.get_window_extent(renderer) #self.offsetbox.set_offset((ox0-_fw*w, oy0-_fh*h)) self.patch.set_bounds(bbox.x0, bbox.y0, bbox.width, bbox.height) x, y = xy_pixel ox1, oy1 = x, y if self.arrowprops: x0, y0 = x, y d = self.arrowprops.copy() # Use FancyArrowPatch if self.arrowprops has "arrowstyle" key. # adjust the starting point of the arrow relative to # the textbox. # TODO : Rotation needs to be accounted. relpos = self._arrow_relpos ox0 = bbox.x0 + bbox.width * relpos[0] oy0 = bbox.y0 + bbox.height * relpos[1] # The arrow will be drawn from (ox0, oy0) to (ox1, # oy1). It will be first clipped by patchA and patchB. # Then it will be shrunk by shrinkA and shrinkB # (in points). If patch A is not set, self.bbox_patch # is used. self.arrow_patch.set_positions((ox0, oy0), (ox1, oy1)) fs = self.prop.get_size_in_points() mutation_scale = d.pop("mutation_scale", fs) mutation_scale = renderer.points_to_pixels(mutation_scale) self.arrow_patch.set_mutation_scale(mutation_scale) patchA = d.pop("patchA", self.patch) self.arrow_patch.set_patchA(patchA)
Example #30
Source File: vis_utils.py From nucleus7 with Mozilla Public License 2.0 | 4 votes |
def _draw_edge_between_keys(nucleotide: Nucleotide, inbound_nucleotide: Nucleotide, incoming_key: str, generated_key: str, nucleotide_plot: _NUCLEOTIDE_PLOT, inbound_nucleotide_plot: _NUCLEOTIDE_PLOT ) -> patches.FancyArrowPatch: if incoming_key not in nucleotide.incoming_keys_all: incoming_key = "DYNAMIC" if generated_key not in inbound_nucleotide.generated_keys_all: generated_key = "DYNAMIC" generated_key_wedge_patch = ( inbound_nucleotide_plot.generated_keys[ generated_key]) incoming_key_wedge_patch = ( nucleotide_plot.incoming_keys[incoming_key]) position0, _ = _get_wedge_center_and_angle( generated_key_wedge_patch.center, generated_key_wedge_patch.r - generated_key_wedge_patch.width, generated_key_wedge_patch.theta1, generated_key_wedge_patch.theta2, generated_key_wedge_patch.width * 2, ) position1, _ = _get_wedge_center_and_angle( incoming_key_wedge_patch.center, incoming_key_wedge_patch.r - incoming_key_wedge_patch.width, incoming_key_wedge_patch.theta1, incoming_key_wedge_patch.theta2, incoming_key_wedge_patch.width * 2, ) seed = np.abs( hash(":".join([inbound_nucleotide.name, incoming_key, nucleotide.name, generated_key])) >> 32) seed = np.clip(seed, 1, 2 ** 32 - 2) np.random.seed(seed) color = np.random.rand(3) edge_patch = patches.FancyArrowPatch( posA=position0, posB=position1, arrowstyle='-|>', mutation_scale=10, edgecolor=color, ) return edge_patch