@@ -10368,22 +10368,35 @@ def test_errorbar_uses_rcparams():
1036810368 assert_allclose (barcol .get_linewidths (), 1.75 )
1036910369
1037010370
10371+ def test_matshow_not_multivariate ():
10372+ """
10373+ matshow() currently does not support multivariate/bivariate colormaps.
10374+ This test is to ensure coverage for the if-statement that checks for this.
10375+
10376+ This test should be removed if matshow() is updated to support
10377+ multivariate/bivariate colormaps.
10378+ """
10379+ fig , axes = plt .subplots ()
10380+ arr = np .arange (24 ).reshape ((- 1 , 4 , 2 ))
10381+ with pytest .raises (TypeError , match = "Invalid shape" ):
10382+ axes .matshow (arr )
10383+
10384+
1037110385@image_comparison (["bivariate_visualizations.png" ], style = 'mpl20' )
1037210386def test_bivariate_visualizations ():
1037310387 x_0 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ) % 5
1037410388 x_1 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ).T % 5
1037510389
10376- fig , axes = plt .subplots (1 , 6 , figsize = (10 , 2 ))
10390+ fig , axes = plt .subplots (1 , 5 , figsize = (8 , 2 ))
1037710391
1037810392 axes [0 ].imshow ((x_0 , x_1 ), cmap = 'BiPeak' , interpolation = 'nearest' )
10379- axes [1 ].matshow ((x_0 , x_1 ), cmap = 'BiPeak' )
10380- axes [2 ].pcolor ((x_0 , x_1 ), cmap = 'BiPeak' )
10381- axes [3 ].pcolormesh ((x_0 , x_1 ), cmap = 'BiPeak' )
10393+ axes [1 ].pcolor ((x_0 , x_1 ), cmap = 'BiPeak' )
10394+ axes [2 ].pcolormesh ((x_0 , x_1 ), cmap = 'BiPeak' )
1038210395
1038310396 x = np .arange (5 )
1038410397 y = np .arange (5 )
1038510398 X , Y = np .meshgrid (x , y )
10386- axes [4 ].pcolormesh (X , Y , (x_0 , x_1 ), cmap = 'BiPeak' )
10399+ axes [3 ].pcolormesh (X , Y , (x_0 , x_1 ), cmap = 'BiPeak' )
1038710400
1038810401 patches = [
1038910402 mpl .patches .Wedge ((.3 , .7 ), .1 , 0 , 360 ), # Full circle
@@ -10395,7 +10408,7 @@ def test_bivariate_visualizations():
1039510408 colors_1 = np .arange (len (patches )) % 2
1039610409 p = mpl .collections .PatchCollection (patches , cmap = 'BiPeak' , alpha = 0.5 )
1039710410 p .set_array ((colors_0 , colors_1 ))
10398- axes [5 ].add_collection (p )
10411+ axes [4 ].add_collection (p )
1039910412 remove_ticks_and_titles (fig )
1040010413
1040110414
@@ -10405,17 +10418,16 @@ def test_multivariate_visualizations():
1040510418 x_1 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ).T % 5
1040610419 x_2 = np .arange (25 , dtype = 'float32' ).reshape (5 , 5 ) % 6
1040710420
10408- fig , axes = plt .subplots (1 , 6 , figsize = (10 , 2 ))
10421+ fig , axes = plt .subplots (1 , 5 , figsize = (8 , 2 ))
1040910422
1041010423 axes [0 ].imshow ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
10411- axes [1 ].matshow ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
10412- axes [2 ].pcolor ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
10413- axes [3 ].pcolormesh ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
10424+ axes [1 ].pcolor ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
10425+ axes [2 ].pcolormesh ((x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
1041410426
1041510427 x = np .arange (5 )
1041610428 y = np .arange (5 )
1041710429 X , Y = np .meshgrid (x , y )
10418- axes [4 ].pcolormesh (X , Y , (x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
10430+ axes [3 ].pcolormesh (X , Y , (x_0 , x_1 , x_2 ), cmap = '3VarAddA' )
1041910431
1042010432 patches = [
1042110433 mpl .patches .Wedge ((.3 , .7 ), .1 , 0 , 360 ), # Full circle
@@ -10428,7 +10440,7 @@ def test_multivariate_visualizations():
1042810440 colors_2 = np .arange (len (patches )) % 3
1042910441 p = mpl .collections .PatchCollection (patches , cmap = '3VarAddA' , alpha = 0.5 )
1043010442 p .set_array ((colors_0 , colors_1 , colors_2 ))
10431- axes [5 ].add_collection (p )
10443+ axes [4 ].add_collection (p )
1043210444 remove_ticks_and_titles (fig )
1043310445
1043410446
0 commit comments