44from matplotlib .testing .decorators import (image_comparison ,
55 remove_ticks_and_titles )
66import matplotlib .colors as mcolors
7+ from matplotlib import cbook
78import matplotlib as mpl
89import pytest
910import re
@@ -14,7 +15,7 @@ def test_bivariate_visualizations():
1415 x_0 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ) % 5
1516 x_1 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ).T % 5
1617
17- fig , axes = plt .subplots (1 , 6 , figsize = (10 , 2 ))
18+ fig , axes = plt .subplots (1 , 7 , figsize = (12 , 2 ))
1819
1920 axes [0 ].imshow ((x_0 , x_1 ), cmap = 'BiPeak' , interpolation = 'nearest' )
2021 axes [1 ].matshow ((x_0 , x_1 ), cmap = 'BiPeak' )
@@ -24,7 +25,8 @@ def test_bivariate_visualizations():
2425 x = np .arange (5 )
2526 y = np .arange (5 )
2627 X , Y = np .meshgrid (x , y )
27- axes [4 ].pcolormesh (X , Y , (x_0 , x_1 ), cmap = 'BiPeak' )
28+ axes [4 ].pcolor (X , Y , (x_0 , x_1 ), cmap = 'BiPeak' )
29+ axes [5 ].pcolormesh (X , Y , (x_0 , x_1 ), cmap = 'BiPeak' )
2830
2931 patches = [
3032 mpl .patches .Wedge ((.3 , .7 ), .1 , 0 , 360 ), # Full circle
@@ -36,7 +38,7 @@ def test_bivariate_visualizations():
3638 colors_1 = np .arange (len (patches )) % 2
3739 p = mpl .collections .PatchCollection (patches , cmap = 'BiPeak' , alpha = 0.5 )
3840 p .set_array ((colors_0 , colors_1 ))
39- axes [5 ].add_collection (p )
41+ axes [6 ].add_collection (p )
4042
4143 remove_ticks_and_titles (fig )
4244
@@ -47,7 +49,7 @@ def test_multivariate_visualizations():
4749 x_1 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ).T % 5
4850 x_2 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ) % 6
4951
50- fig , axes = plt .subplots (1 , 6 , figsize = (10 , 2 ))
52+ fig , axes = plt .subplots (1 , 7 , figsize = (12 , 2 ))
5153
5254 axes [0 ].imshow ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' , interpolation = 'nearest' )
5355 axes [1 ].matshow ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
@@ -57,7 +59,8 @@ def test_multivariate_visualizations():
5759 x = np .arange (5 )
5860 y = np .arange (5 )
5961 X , Y = np .meshgrid (x , y )
60- axes [4 ].pcolormesh (X , Y , (x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
62+ axes [4 ].pcolor (X , Y , (x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
63+ axes [5 ].pcolormesh (X , Y , (x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
6164
6265 patches = [
6366 mpl .patches .Wedge ((.3 , .7 ), .1 , 0 , 360 ), # Full circle
@@ -70,7 +73,7 @@ def test_multivariate_visualizations():
7073 colors_2 = np .arange (len (patches )) % 3
7174 p = mpl .collections .PatchCollection (patches , cmap = '3VarAddA' , alpha = 0.5 )
7275 p .set_array ((colors_0 , colors_1 , colors_2 ))
73- axes [5 ].add_collection (p )
76+ axes [6 ].add_collection (p )
7477
7578 remove_ticks_and_titles (fig )
7679
@@ -625,52 +628,8 @@ def test_cmap_error():
625628 )):
626629 mpl .collections .PatchCollection ([], cmap = 'not_a_cmap' )
627630
628- if 0 :
629- def test_artist_format_cursor_data_multivar ():
630-
631- X = np .zeros ((3 , 3 ))
632- X [0 , 0 ] = 0.9
633- X [0 , 1 ] = 0.99
634- X [0 , 2 ] = 0.999
635- X [1 , 0 ] = - 1
636- X [1 , 1 ] = 0
637- X [1 , 2 ] = 1
638- X [2 , 0 ] = 0.09
639- X [2 , 1 ] = 0.009
640- X [2 , 2 ] = 0.0009
641-
642- labels_list = [
643- "[0.9, 0.0]" ,
644- "[1., 0.0]" ,
645- "[1., 0.0]" ,
646- "[-1.0, 0.0]" ,
647- "[0.0, 0.0]" ,
648- "[1.0, 0.0]" ,
649- "[0.09, 0.0]" ,
650- "[0.009, 0.0]" ,
651- "[0.0009, 0.0]" ,
652- ]
653-
654- pos = [[0 , 0 ], [1 , 0 ], [2 , 0 ],
655- [0 , 1 ], [1 , 1 ], [2 , 1 ],
656- [0 , 2 ], [1 , 2 ], [2 , 2 ]]
657-
658- from matplotlib .backend_bases import MouseEvent
659-
660- for cmap in ['BiOrangeBlue' , '2VarAddA' ]:
661- fig , ax = plt .subplots ()
662- norm = mpl .colors .BoundaryNorm (np .linspace (- 1 , 1 , 20 ), 256 )
663- data = (X , np .zeros (X .shape ))
664- im = ax .imshow (data , cmap = cmap , norm = (norm , None ))
665-
666- for v , text in zip (pos , labels_list ):
667- xdisp , ydisp = ax .transData .transform (v )
668- event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
669- assert im .format_cursor_data (im .get_cursor_data (event )) == text
670-
671631
672632def test_multivariate_safe_masked_invalid ():
673- from matplotlib import cbook
674633 dt = np .dtype ('float32, float32' ).newbyteorder ('>' )
675634 x = np .zeros (2 , dtype = dt )
676635 x ['f0' ][0 ] = np .nan
0 commit comments