tikzplotlib icon indicating copy to clipboard operation
tikzplotlib copied to clipboard

Clipping image with path

Open larsgrobe opened this issue 2 years ago • 0 comments
trafficstars

Dear all, I am trying to export an imshow image with a set clip_path. Unfortunately, the latter is ignored. Is there any way to get this functionalitiy working, or am I just doing something wrong? Best, Lars.

Example (with an m x n array of pixels and a patch to clip the image to):

fig, ax = plt.subplots(1, 1, figsize=(3.3,3.3))
bbox=patch.get_extents()
axis.add_patch(patch)
im = axis.imshow(dataArray2D, origin='lower', extent=(bbox.xmin, bbox.xmax, bbox.ymin, bbox.ymax))
im.set_clip_path(patch)
axis.set_axis_off()
tikzplotlib.save("clippedIm.tex")

larsgrobe avatar Mar 15 '23 18:03 larsgrobe