@@ -5702,3 +5702,37 @@ def test_empty_errorbar_legend():
57025702def test_plot_columns_cycle_deprecation ():
57035703 with pytest .warns (MatplotlibDeprecationWarning ):
57045704 plt .plot (np .zeros ((2 , 2 )), np .zeros ((2 , 3 )))
5705+
5706+
5707+ def test_zoom_inset ():
5708+
5709+ dx , dy = 0.05 , 0.05
5710+
5711+ # generate 2 2d grids for the x & y bounds
5712+ y , x = np .mgrid [slice (1 , 5 + dy , dy ),
5713+ slice (1 , 5 + dx , dx )]
5714+ z = np .sin (x )** 10 + np .cos (10 + y * x ) * np .cos (x )
5715+
5716+ fig , ax = plt .subplots ()
5717+ ax .pcolormesh (x , y , z )
5718+ ax .set_aspect (1. )
5719+ ax .apply_aspect ()
5720+ # we need to apply_aspect to make the drawing below work.
5721+
5722+ # Make the inset_axes... Position axes co-ordinates...
5723+ axin1 = ax .inset_axes ([0.7 , 0.7 , 0.35 , 0.35 ])
5724+ # redraw the data in the inset axes...
5725+ axin1 .pcolormesh (x , y , z )
5726+ axin1 .set_xlim ([1.5 , 2.15 ])
5727+ axin1 .set_ylim ([2 , 2.5 ])
5728+ axin1 .set_aspect (ax .get_aspect ())
5729+
5730+ rec , connectors = ax .zoom_inset_rectangle (axin1 )
5731+ fig .canvas .draw ()
5732+ xx = np .array ([[1.5 , 2. ],
5733+ [2.15 , 2.5 ]])
5734+ assert (np .all (rec .get_bbox ().get_points () == xx ))
5735+ xx = np .array ([[0.6325 , 0.692308 ],
5736+ [0.8425 , 0.907692 ]])
5737+ np .testing .assert_allclose (axin1 .get_position ().get_points (),
5738+ xx , rtol = 1e-4 )
0 commit comments