本文整理汇总了Python中matplotlib.transforms.TransformedPath方法的典型用法代码示例。如果您正苦于以下问题:Python transforms.TransformedPath方法的具体用法?Python transforms.TransformedPath怎么用?Python transforms.TransformedPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.transforms
的用法示例。
在下文中一共展示了transforms.TransformedPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import TransformedPath [as 别名]
def draw(self, renderer):
"""
Draw the children
"""
dpi_cor = renderer.points_to_pixels(1.)
self.dpi_transform.clear()
self.dpi_transform.scale(dpi_cor, dpi_cor)
# At this point the DrawingArea has a transform
# to the display space so the path created is
# good for clipping children
tpath = mtransforms.TransformedPath(
mpath.Path([[0, 0], [0, self.height],
[self.width, self.height],
[self.width, 0]]),
self.get_transform())
for c in self._children:
if self._clip_children and not (c.clipbox or c._clippath):
c.set_clip_path(tpath)
c.draw(renderer)
bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
self.stale = False
示例2: test_imshow_clip
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import TransformedPath [as 别名]
def test_imshow_clip():
# As originally reported by Gellule Xg <gellule.xg@free.fr>
#Create a NxN image
N = 100
(x, y) = np.indices((N, N))
x -= N//2
y -= N//2
r = np.sqrt(x**2+y**2-x*y)
#Create a contour plot at N/4 and extract both the clip path and transform
fig = plt.figure()
ax = fig.add_subplot(111)
c = ax.contour(r, [N/4])
x = c.collections[0]
clipPath = x.get_paths()[0]
clipTransform = x.get_transform()
from matplotlib.transforms import TransformedPath
clip_path = TransformedPath(clipPath, clipTransform)
#Plot the image clipped by the contour
ax.imshow(r, clip_path=clip_path)
示例3: test_imshow_clip
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import TransformedPath [as 别名]
def test_imshow_clip():
# As originally reported by Gellule Xg <gellule.xg@free.fr>
# Create a NxN image
N = 100
(x, y) = np.indices((N, N))
x -= N//2
y -= N//2
r = np.sqrt(x**2+y**2-x*y)
# Create a contour plot at N/4 and extract both the clip path and transform
fig, ax = plt.subplots()
c = ax.contour(r, [N/4])
x = c.collections[0]
clipPath = x.get_paths()[0]
clipTransform = x.get_transform()
from matplotlib.transforms import TransformedPath
clip_path = TransformedPath(clipPath, clipTransform)
# Plot the image clipped by the contour
ax.imshow(r, clip_path=clip_path)
示例4: test_transformed_path
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import TransformedPath [as 别名]
def test_transformed_path():
points = [(0, 0), (1, 0), (1, 1), (0, 1)]
codes = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]
path = Path(points, codes)
trans = mtransforms.Affine2D()
trans_path = mtransforms.TransformedPath(path, trans)
assert_allclose(trans_path.get_fully_transformed_path().vertices, points)
# Changing the transform should change the result.
r2 = 1 / np.sqrt(2)
trans.rotate(np.pi / 4)
assert_allclose(trans_path.get_fully_transformed_path().vertices,
[(0, 0), (r2, r2), (0, 2 * r2), (-r2, r2)],
atol=1e-15)
# Changing the path does not change the result (it's cached).
path.points = [(0, 0)] * 4
assert_allclose(trans_path.get_fully_transformed_path().vertices,
[(0, 0), (r2, r2), (0, 2 * r2), (-r2, r2)],
atol=1e-15)
示例5: set_clip_path
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import TransformedPath [as 别名]
def set_clip_path(self, path):
"""
Set the clip path and transformation. Path should be a
:class:`~matplotlib.transforms.TransformedPath` instance.
"""
assert path is None or isinstance(path, transforms.TransformedPath)
self._clippath = path