nschloe / tikzplotlib

:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.
MIT License
2.43k stars 218 forks source link

Clipping image with path #575

Open larsgrobe opened 1 year ago

larsgrobe commented 1 year ago

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")