本文整理匯總了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