@@ -30,24 +30,37 @@ def imshow_affine(ax, z, *kl, **kwargs):
3030
3131
3232if 1 :
33- ax = plt .subplot (111 )
33+
34+ # image rotation
35+
36+ ax1 = plt .subplot (121 )
3437 Z = get_image ()
35- im = imshow_affine (ax , Z , interpolation = 'nearest' , cmap = cm .jet ,
36- origin = 'lower' ,
37- extent = [- 2 , 4 , - 3 , 2 ], clip_on = True )
38+ im1 = imshow_affine (ax1 , Z , interpolation = 'nearest' , cmap = cm .jet ,
39+ origin = 'lower' ,
40+ extent = [- 2 , 4 , - 3 , 2 ], clip_on = True )
3841
39- trans_data2 = mtransforms .Affine2D ().rotate_deg (30 ) + ax .transData
40- im .set_transform (trans_data2 )
42+ trans_data2 = mtransforms .Affine2D ().rotate_deg (30 ) + ax1 .transData
43+ im1 .set_transform (trans_data2 )
4144
4245 # display intended extent of the image
43- x1 , x2 , y1 , y2 = im .get_extent ()
46+ x1 , x2 , y1 , y2 = im1 .get_extent ()
4447 x3 , y3 = x2 , y1
4548
46- ax .plot ([x1 , x2 , x2 , x1 , x1 ], [y1 , y1 , y2 , y2 , y1 ], "r--" , lw = 3 ,
47- transform = trans_data2 )
49+ ax1 .plot ([x1 , x2 , x2 , x1 , x1 ], [y1 , y1 , y2 , y2 , y1 ], "r--" , lw = 3 ,
50+ transform = trans_data2 )
51+
52+ ax1 .set_xlim (- 3 , 5 )
53+ ax1 .set_ylim (- 4 , 4 )
54+
55+
56+ # image skew
57+
58+ ax2 = plt .subplot (122 )
59+ im2 = ax2 .imshow (Z , interpolation = 'nearest' , cmap = cm .jet ,
60+ origin = 'lower' ,
61+ extent = [- 2 , 4 , - 3 , 2 ], clip_on = True )
62+ im2 ._image_skew_coordinate = (3 , - 2 )
4863
49- ax .set_xlim (- 3 , 5 )
50- ax .set_ylim (- 4 , 4 )
5164
5265 plt .show ()
5366 #plt.savefig("demo_affine_image")
0 commit comments