Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita43e3a0

Browse files
committed
PGF backend: support affine image transformations
1 parent40fe31c commita43e3a0

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

‎lib/matplotlib/backends/backend_pgf.py‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,20 @@ def _pgf_path_draw(self, stroke=True, fill=False):
609609
actions.append("fill")
610610
writeln(self.fh,r"\pgfusepath{%s}"%",".join(actions))
611611

612-
defdraw_image(self,gc,x,y,im):
612+
defoption_scale_image(self):
613+
"""
614+
pgf backend supports affine transform of image.
615+
"""
616+
returnTrue
617+
618+
defoption_image_nocomposite(self):
619+
"""
620+
return whether to generate a composite image from multiple images on
621+
a set of axes
622+
"""
623+
returnnotrcParams['image.composite_image']
624+
625+
defdraw_image(self,gc,x,y,im,transform=None):
613626
# TODO: Almost no documentation for the behavior of this function.
614627
# Something missing?
615628
h,w=im.shape[:2]
@@ -627,7 +640,17 @@ def draw_image(self, gc, x, y, im):
627640
writeln(self.fh,r"\begin{pgfscope}")
628641
self._print_pgf_clip(gc)
629642
f=1./self.dpi# from display coords to inch
630-
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))
643+
iftransformisnotNone:
644+
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))
652+
interp=str(transformisNone).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))
631654
writeln(self.fh,r"\end{pgfscope}")
632655

633656
defdraw_tex(self,gc,x,y,s,prop,angle,ismath="TeX!",mtext=None):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp