Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 468a977

Browse files
committed
PGF backend: skip drawing of empty images
1 parent 2cdb5aa commit 468a977

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ def _pgf_path_draw(self, stroke=True, fill=False):
612612
def draw_image(self, gc, x, y, im):
613613
# TODO: Almost no documentation for the behavior of this function.
614614
# Something missing?
615+
h, w = im.shape[:2]
616+
if w == 0 or h == 0:
617+
return
615618

616619
# save the images to png files
617620
path = os.path.dirname(self.fh.name)
@@ -623,7 +626,6 @@ def draw_image(self, gc, x, y, im):
623626
# reference the image in the pgf picture
624627
writeln(self.fh, r"\begin{pgfscope}")
625628
self._print_pgf_clip(gc)
626-
h, w = im.shape[:2]
627629
f = 1. / self.dpi # from display coords to inch
628630
writeln(self.fh, r"\pgftext[at=\pgfqpoint{%fin}{%fin},left,bottom]{\pgfimage[interpolate=true,width=%fin,height=%fin]{%s}}" % (x * f, y * f, w * f, h * f, fname_img))
629631
writeln(self.fh, r"\end{pgfscope}")

0 commit comments

Comments
 (0)