33from matplotlib .testing .decorators import check_figures_equal
44from matplotview import view , inset_zoom_axes
55
6+ @check_figures_equal (tol = 3 )
7+ def test_double_plot (fig_test , fig_ref ):
8+ np .random .seed (1 )
9+ im_data = np .random .rand (30 , 30 )
10+
11+ # Test case...
12+ ax_test1 , ax_test2 = fig_test .subplots (1 , 2 )
13+
14+ ax_test1 .plot ([i for i in range (10 )], "r" )
15+ ax_test1 .add_patch (plt .Circle ((3 , 3 ), 1 , ec = "black" , fc = "blue" ))
16+ ax_test1 .imshow (im_data , origin = "lower" , cmap = "Blues" , alpha = 0.5 ,
17+ interpolation = "nearest" )
18+ ax_test2 = view (ax_test2 , ax_test1 )
19+ ax_test2 .set_aspect (ax_test1 .get_aspect ())
20+ ax_test2 .set_xlim (ax_test1 .get_xlim ())
21+ ax_test2 .set_ylim (ax_test1 .get_ylim ())
22+
23+ # Reference...
24+ ax_ref1 , ax_ref2 = fig_ref .subplots (1 , 2 )
25+
26+ ax_ref1 .plot ([i for i in range (10 )], "r" )
27+ ax_ref1 .add_patch (plt .Circle ((3 , 3 ), 1 , ec = "black" , fc = "blue" ))
28+ ax_ref1 .imshow (im_data , origin = "lower" , cmap = "Blues" , alpha = 0.5 ,
29+ interpolation = "nearest" )
30+ ax_ref2 .plot ([i for i in range (10 )], "r" )
31+ ax_ref2 .add_patch (plt .Circle ((3 , 3 ), 1 , ec = "black" , fc = "blue" ))
32+ ax_ref2 .imshow (im_data , origin = "lower" , cmap = "Blues" , alpha = 0.5 ,
33+ interpolation = "nearest" )
34+
35+
636# Tolerance needed because the way the auto-zoom axes handles images is
737# entirely different, leading to a slightly different result.
8- @check_figures_equal (tol = 3 )
38+ @check_figures_equal (tol = 3.5 )
939def test_auto_zoom_inset (fig_test , fig_ref ):
1040 np .random .seed (1 )
1141 im_data = np .random .rand (30 , 30 )
@@ -35,5 +65,4 @@ def test_auto_zoom_inset(fig_test, fig_ref):
3565 axins_ref .add_patch (plt .Circle ((3 , 3 ), 1 , ec = "black" , fc = "blue" ))
3666 axins_ref .imshow (im_data , origin = "lower" , cmap = "Blues" , alpha = 0.5 ,
3767 interpolation = "nearest" )
38- ax_ref .indicate_inset_zoom (axins_ref , edgecolor = "black" )
39-
68+ ax_ref .indicate_inset_zoom (axins_ref , edgecolor = "black" )
0 commit comments