Skip to content

Commit

Permalink
PGF backend: slightly simplify image drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
f0k committed Jul 19, 2016
1 parent be54fae commit f821bf6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,13 @@ def draw_image(self, gc, x, y, im, transform=None):
writeln(self.fh, r"\begin{pgfscope}")
self._print_pgf_clip(gc)
f = 1. / self.dpi # from display coords to inch
writeln(self.fh, r"\pgftext[at=\pgfqpoint{%fin}{%fin},left,bottom]{" % (x * f, y * f))
if transform is not None:
tr1, tr2, tr3, tr4, tr5, tr6 = transform.frozen().to_values()
# scale is already included in the above transform
w, h = 1, 1
# translation can be merged into this transform (makes it easier)
tr5 += x
tr6 += y
x, y = 0, 0
writeln(self.fh, r"\makeatletter\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}\makeatother" % (tr1, tr2, tr3, tr4, tr5 * f, tr6 * f))
w = h = self.dpi # scale is already included in the transform
writeln(self.fh, r"\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}" % (tr1 * f, tr2 * f, tr3 * f, tr4 * f, tr5 * f, tr6 * f))
interp = str(transform is None).lower() # interpolation in PDF reader
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))
writeln(self.fh, r"\pgfimage[interpolate=%s,width=%fin,height=%fin]{%s}}" % (interp, w * f, h * f, fname_img))
writeln(self.fh, r"\end{pgfscope}")

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

0 comments on commit f821bf6

Please sign in to comment.