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

Skip to content

Commit f821bf6

Browse files
committed
PGF backend: slightly simplify image drawing
1 parent be54fae commit f821bf6

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -640,17 +640,13 @@ def draw_image(self, gc, x, y, im, transform=None):
640640
writeln(self.fh, r"\begin{pgfscope}")
641641
self._print_pgf_clip(gc)
642642
f = 1. / self.dpi # from display coords to inch
643+
writeln(self.fh, r"\pgftext[at=\pgfqpoint{%fin}{%fin},left,bottom]{" % (x * f, y * f))
643644
if transform is not None:
644645
tr1, tr2, tr3, tr4, tr5, tr6 = transform.frozen().to_values()
645-
# scale is already included in the above transform
646-
w, h = 1, 1
647-
# translation can be merged into this transform (makes it easier)
648-
tr5 += x
649-
tr6 += y
650-
x, y = 0, 0
651-
writeln(self.fh, r"\makeatletter\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}\makeatother" % (tr1, tr2, tr3, tr4, tr5 * f, tr6 * f))
646+
w = h = self.dpi # scale is already included in the transform
647+
writeln(self.fh, r"\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}" % (tr1 * f, tr2 * f, tr3 * f, tr4 * f, tr5 * f, tr6 * f))
652648
interp = str(transform is None).lower() # interpolation in PDF reader
653-
writeln(self.fh, r"\pgftext[at=\pgfqpoint{%fin}{%fin},left,bottom]{\pgfimage[interpolate=%s,width=%fin,height=%fin]{%s}}" % (x * f, y * f, interp, w * f, h * f, fname_img))
649+
writeln(self.fh, r"\pgfimage[interpolate=%s,width=%fin,height=%fin]{%s}}" % (interp, w * f, h * f, fname_img))
654650
writeln(self.fh, r"\end{pgfscope}")
655651

656652
def draw_tex(self, gc, x, y, s, prop, angle, ismath="TeX!", mtext=None):

0 commit comments

Comments
 (0)