本文整理汇总了Python中matplotlib.patches.FancyArrowPatch.set_linestyle方法的典型用法代码示例。如果您正苦于以下问题:Python FancyArrowPatch.set_linestyle方法的具体用法?Python FancyArrowPatch.set_linestyle怎么用?Python FancyArrowPatch.set_linestyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.FancyArrowPatch
的用法示例。
在下文中一共展示了FancyArrowPatch.set_linestyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _render_on_subplot
# 需要导入模块: from matplotlib.patches import FancyArrowPatch [as 别名]
# 或者: from matplotlib.patches.FancyArrowPatch import set_linestyle [as 别名]
def _render_on_subplot(self, subplot):
"""
Render this arrow in a subplot. This is the key function that
defines how this arrow graphics primitive is rendered in
matplotlib's library.
EXAMPLES::
This function implicitly ends up rendering this arrow on a matplotlib subplot:
sage: arrow(path=[[(0,1), (2,-1), (4,5)]])
"""
from sage.plot.misc import get_matplotlib_linestyle
options = self.options()
width = float(options['width'])
head = options.pop('head')
if head == 0: style = '<|-'
elif head == 1: style = '-|>'
elif head == 2: style = '<|-|>'
else: raise KeyError('head parameter must be one of 0 (start), 1 (end) or 2 (both).')
arrowsize = float(options.get('arrowsize',5))
head_width=arrowsize
head_length=arrowsize*2.0
color = to_mpl_color(options['rgbcolor'])
from matplotlib.patches import FancyArrowPatch
from matplotlib.path import Path
bpath = Path(self.vertices, self.codes)
p = FancyArrowPatch(path=bpath,
lw=width, arrowstyle='%s,head_width=%s,head_length=%s'%(style,head_width, head_length),
fc=color, ec=color)
p.set_linestyle(get_matplotlib_linestyle(options['linestyle'],return_type='long'))
p.set_zorder(options['zorder'])
p.set_label(options['legend_label'])
subplot.add_patch(p)
return p
示例2: _render_on_subplot
# 需要导入模块: from matplotlib.patches import FancyArrowPatch [as 别名]
# 或者: from matplotlib.patches.FancyArrowPatch import set_linestyle [as 别名]
def _render_on_subplot(self, subplot):
"""
Render this arrow in a subplot. This is the key function that
defines how this arrow graphics primitive is rendered in
matplotlib's library.
EXAMPLES::
This function implicitly ends up rendering this arrow on a matplotlib subplot:
sage: arrow(path=[[(0,1), (2,-1), (4,5)]])
Graphics object consisting of 1 graphics primitive
"""
from sage.plot.misc import get_matplotlib_linestyle
options = self.options()
width = float(options["width"])
head = options.pop("head")
if head == 0:
style = "<|-"
elif head == 1:
style = "-|>"
elif head == 2:
style = "<|-|>"
else:
raise KeyError("head parameter must be one of 0 (start), 1 (end) or 2 (both).")
arrowsize = float(options.get("arrowsize", 5))
head_width = arrowsize
head_length = arrowsize * 2.0
color = to_mpl_color(options["rgbcolor"])
from matplotlib.patches import FancyArrowPatch
from matplotlib.path import Path
bpath = Path(self.vertices, self.codes)
p = FancyArrowPatch(
path=bpath,
lw=width,
arrowstyle="%s,head_width=%s,head_length=%s" % (style, head_width, head_length),
fc=color,
ec=color,
)
p.set_linestyle(get_matplotlib_linestyle(options["linestyle"], return_type="long"))
p.set_zorder(options["zorder"])
p.set_label(options["legend_label"])
subplot.add_patch(p)
return p
示例3: _render_on_subplot
# 需要导入模块: from matplotlib.patches import FancyArrowPatch [as 别名]
# 或者: from matplotlib.patches.FancyArrowPatch import set_linestyle [as 别名]
def _render_on_subplot(self, subplot):
r"""
Render this arrow in a subplot. This is the key function that
defines how this arrow graphics primitive is rendered in
matplotlib's library.
EXAMPLES:
This function implicitly ends up rendering this arrow on
a matplotlib subplot::
sage: arrow((0,1), (2,-1))
TESTS:
The length of the ends (shrinkA and shrinkB) should not depend
on the width of the arrow, because Matplotlib already takes
this into account. See :trac:`12836`::
sage: fig = Graphics().matplotlib()
sage: sp = fig.add_subplot(1,1,1)
sage: a = arrow((0,0), (1,1))
sage: b = arrow((0,0), (1,1), width=20)
sage: p1 = a[0]._render_on_subplot(sp)
sage: p2 = b[0]._render_on_subplot(sp)
sage: p1.shrinkA == p2.shrinkA
True
sage: p1.shrinkB == p2.shrinkB
True
Dashed arrows should have solid arrowheads,
:trac:`12852`. This test saves the plot of a dashed arrow to
an EPS file. Within the EPS file, ``stroke`` will be called
twice: once to draw the line, and again to draw the
arrowhead. We check that both calls do not occur while the
dashed line style is enabled::
sage: a = arrow((0,0), (1,1), linestyle='dashed')
sage: filename = tmp_filename(ext='.eps')
sage: a.save(filename=filename)
sage: with open(filename, 'r') as f:
....: contents = f.read().replace('\n', ' ')
sage: two_stroke_pattern = r'setdash.*stroke.*stroke.*setdash'
sage: import re
sage: two_stroke_re = re.compile(two_stroke_pattern)
sage: two_stroke_re.search(contents) is None
True
"""
from sage.plot.misc import get_matplotlib_linestyle
options = self.options()
head = options.pop("head")
if head == 0:
style = "<|-"
elif head == 1:
style = "-|>"
elif head == 2:
style = "<|-|>"
else:
raise KeyError("head parameter must be one of 0 (start), 1 (end) or 2 (both).")
width = float(options["width"])
arrowshorten_end = float(options.get("arrowshorten", 0)) / 2.0
arrowsize = float(options.get("arrowsize", 5))
head_width = arrowsize
head_length = arrowsize * 2.0
color = to_mpl_color(options["rgbcolor"])
from matplotlib.patches import FancyArrowPatch
p = FancyArrowPatch(
(self.xtail, self.ytail),
(self.xhead, self.yhead),
lw=width,
arrowstyle="%s,head_width=%s,head_length=%s" % (style, head_width, head_length),
shrinkA=arrowshorten_end,
shrinkB=arrowshorten_end,
fc=color,
ec=color,
)
p.set_linestyle(get_matplotlib_linestyle(options["linestyle"], return_type="long"))
p.set_zorder(options["zorder"])
p.set_label(options["legend_label"])
if options["linestyle"] != "solid":
# The next few lines work around a design issue in matplotlib. Currently, the specified
# linestyle is used to draw both the path and the arrowhead. If linestyle is 'dashed', this
# looks really odd. This code is from Jae-Joon Lee in response to a post to the matplotlib mailing
# list. See http://sourceforge.net/mailarchive/forum.php?thread_name=CAG%3DuJ%2Bnw2dE05P9TOXTz_zp-mGP3cY801vMH7yt6vgP9_WzU8w%40mail.gmail.com&forum_name=matplotlib-users
import matplotlib.patheffects as pe
class CheckNthSubPath(object):
def __init__(self, patch, n):
"""
creates an callable object that returns True if the provided
path is the n-th path from the patch.
"""
self._patch = patch
self._n = n
def get_paths(self, renderer):
#.........这里部分代码省略.........