本文整理汇总了Python中matplotlib.patches.PathPatch.set_alpha方法的典型用法代码示例。如果您正苦于以下问题:Python PathPatch.set_alpha方法的具体用法?Python PathPatch.set_alpha怎么用?Python PathPatch.set_alpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.PathPatch
的用法示例。
在下文中一共展示了PathPatch.set_alpha方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scatter
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_alpha [as 别名]
def scatter(self, x, y, s, ax=None, fancy=False, **kwargs):
""" takes data coordinate x, y and plot them to a data coordinate axes,
s is the radius in data units.
When fancy is True, apply a radient filter so that the
edge is blent into the background; better with marker='o' or marker='+'. """
X, Y, S = numpy.asarray([x, y, s])
if ax is None: ax=self.default_axes
def filter(image, dpi):
# this is problematic if the marker is clipped.
if image.shape[0] <=1 and image.shape[1] <=1: return image
xgrad = 1.0 \
- numpy.fabs(numpy.linspace(0, 2,
image.shape[0], endpoint=True) - 1.0)
ygrad = 1.0 \
- numpy.fabs(numpy.linspace(0, 2,
image.shape[1], endpoint=True) - 1.0)
image[..., 3] *= xgrad[:, None] ** 0.5
image[..., 3] *= ygrad[None, :] ** 0.5
return image, 0, 0
marker = kwargs.pop('marker', 'x')
verts = kwargs.pop('verts', None)
# to be API compatible
if marker is None and not (verts is None):
marker = (verts, 0)
verts = None
objs = []
color = kwargs.pop('color', None)
edgecolor = kwargs.pop('edgecolor', None)
linewidth = kwargs.pop('linewidth', kwargs.pop('lw', None))
marker_obj = MarkerStyle(marker)
if not marker_obj.is_filled():
edgecolor = color
for x,y,r in numpy.nditer([X, Y, S], flags=['zerosize_ok']):
path = marker_obj.get_path().transformed(
marker_obj.get_transform().scale(r).translate(x, y))
obj = PathPatch(
path,
facecolor = color,
edgecolor = edgecolor,
linewidth = linewidth,
transform = ax.transData,
)
obj.set_alpha(1.0)
if fancy:
obj.set_agg_filter(filter)
obj.rasterized = True
objs += [obj]
ax.add_artist(obj)
ax.autoscale_view()
return objs
示例2: _render_on_subplot
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_alpha [as 别名]
def _render_on_subplot(self, subplot):
"""
Render this Bezier path in a subplot. This is the key function that
defines how this Bezier path graphics primitive is rendered in matplotlib's
library.
TESTS::
sage: bezier_path([[(0,1),(.5,0),(1,1)]])
Graphics object consisting of 1 graphics primitive
::
sage: bezier_path([[(0,1),(.5,0),(1,1),(-3,5)]])
Graphics object consisting of 1 graphics primitive
"""
from matplotlib.patches import PathPatch
from matplotlib.path import Path
from sage.plot.misc import get_matplotlib_linestyle
options = dict(self.options())
del options['alpha']
del options['thickness']
del options['rgbcolor']
del options['zorder']
del options['fill']
del options['linestyle']
bpath = Path(self.vertices, self.codes)
bpatch = PathPatch(bpath, **options)
options = self.options()
bpatch.set_linewidth(float(options['thickness']))
bpatch.set_fill(options['fill'])
bpatch.set_zorder(options['zorder'])
a = float(options['alpha'])
bpatch.set_alpha(a)
c = to_mpl_color(options['rgbcolor'])
bpatch.set_edgecolor(c)
bpatch.set_facecolor(c)
bpatch.set_linestyle(get_matplotlib_linestyle(options['linestyle'], return_type='long'))
subplot.add_patch(bpatch)