本文整理汇总了Python中matplotlib.patches.PathPatch.rasterized方法的典型用法代码示例。如果您正苦于以下问题:Python PathPatch.rasterized方法的具体用法?Python PathPatch.rasterized怎么用?Python PathPatch.rasterized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.PathPatch
的用法示例。
在下文中一共展示了PathPatch.rasterized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scatter
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import rasterized [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