本文整理汇总了Python中matplotlib.patches.FancyArrowPatch方法的典型用法代码示例。如果您正苦于以下问题:Python patches.FancyArrowPatch方法的具体用法?Python patches.FancyArrowPatch怎么用?Python patches.FancyArrowPatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches
的用法示例。
在下文中一共展示了patches.FancyArrowPatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_bbox_position_size
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)
示例2: __prepare_fancyarrow_dpi_cor_test
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
示例3: test_fancyarrow_dash
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)
示例4: create_edge_patch
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
)
示例5: __prepare_fancyarrow_dpi_cor_test
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
示例6: _draw_without_key_connections
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
示例7: _draw_with_key_connections
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
示例8: _draw_nucleotide_keys_connections
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
示例9: _draw_key_connections_for_nucleotide_pair
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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
示例10: test_fancyarrow_dpi_cor_100dpi
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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()
示例11: test_arrow_styles
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)
示例12: test_invalid_intersection
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)
示例13: add_arrow
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)
示例14: set_arrow_alpha
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)
示例15: draw
# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyArrowPatch [as 别名]
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)