-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
pgf: draw_image() doesn't store path to png files in the pgf source #1509
Copy link
Copy link
Closed
Description
If a figure with an image is to be saved as 'path/file.pgf', the png file of the image is written into path. However the \pgfimage command in the pgf file omits the path. The following patch fixes this problem for me (not tested in any other way):
--- a/lib/matplotlib/backends/backend_pgf.py
+++ b/lib/matplotlib/backends/backend_pgf.py
@@ -581,11 +581,12 @@ class RendererPgf(RendererBase):
# save the images to png files
path = os.path.dirname(self.fh.name)
fname = os.path.splitext(os.path.basename(self.fh.name))[0]
- fname_img = "%s-img%d.png" % (fname, self.image_counter)
+ fname_img = os.path.join(path,
+ "%s-img%d.png" % (fname, self.image_counter))
self.image_counter += 1
im.flipud_out()
rows, cols, buf = im.as_rgba_str()
- _png.write_png(buf, cols, rows, os.path.join(path, fname_img))
+ _png.write_png(buf, cols, rows, fname_img)
# reference the image in the pgf picture
writeln(self.fh, r"\begin{pgfscope}")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels