本文整理汇总了Python中matplotlib.backend_bases.RendererBase.stop_filter方法的典型用法代码示例。如果您正苦于以下问题:Python RendererBase.stop_filter方法的具体用法?Python RendererBase.stop_filter怎么用?Python RendererBase.stop_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backend_bases.RendererBase
的用法示例。
在下文中一共展示了RendererBase.stop_filter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stop_filter
# 需要导入模块: from matplotlib.backend_bases import RendererBase [as 别名]
# 或者: from matplotlib.backend_bases.RendererBase import stop_filter [as 别名]
def stop_filter(self, post_processing):
return RendererBase.stop_filter(self, post_processing)
"""
Save the plot in the current canvas as a image and apply
the *post_processing* function.
def post_processing(image, dpi):
# ny, nx, depth = image.shape
# image (numpy array) has RGBA channels and has a depth of 4.
...
# create a new_image (numpy array of 4 channels, size can be
# different). The resulting image may have offsets from
# lower-left corner of the original image
return new_image, offset_x, offset_y
The saved renderer is restored and the returned image from
post_processing is plotted (using draw_image) on it.
"""
# WARNING.
# For agg_filter to work, the rendere's method need
# to overridden in the class. See draw_markers, and draw_path_collections
from matplotlib._image import fromarray
width, height = int(self.width), int(self.height)
buffer, bounds = self._renderer.tostring_rgba_minimized()
l, b, w, h = bounds
self._renderer = self._filter_renderers.pop()
self._update_methods()
if w > 0 and h > 0:
img = np.fromstring(buffer, np.uint8)
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
self.dpi)
image = fromarray(np.flipud(img), 1)
# image.flipud_out()
gc = self.new_gc()
self._renderer.draw_image(gc,
l+ox, height - b - h +oy,
image)