@@ -914,13 +914,13 @@ def test_quadmesh_vmin_vmax():
914
914
norm = mpl .colors .Normalize (vmin = 0 , vmax = 1 )
915
915
coll = ax .pcolormesh ([[1 ]], cmap = cmap , norm = norm )
916
916
fig .canvas .draw ()
917
- assert np .array_equal (coll .get_facecolors ()[0 , :], cmap (norm (1 )))
917
+ assert np .array_equal (coll .get_facecolors ()[0 , 0 , :], cmap (norm (1 )))
918
918
919
919
# Change the vmin/vmax of the norm so that the color is from
920
920
# the bottom of the colormap now
921
921
norm .vmin , norm .vmax = 1 , 2
922
922
fig .canvas .draw ()
923
- assert np .array_equal (coll .get_facecolors ()[0 , :], cmap (norm (1 )))
923
+ assert np .array_equal (coll .get_facecolors ()[0 , 0 , :], cmap (norm (1 )))
924
924
925
925
926
926
def test_quadmesh_alpha_array ():
@@ -935,16 +935,16 @@ def test_quadmesh_alpha_array():
935
935
coll2 = ax1 .pcolormesh (x , y , z )
936
936
coll2 .set_alpha (alpha )
937
937
plt .draw ()
938
- assert_array_equal (coll1 .get_facecolors ()[: , - 1 ], alpha_flat )
939
- assert_array_equal (coll2 .get_facecolors ()[: , - 1 ], alpha_flat )
938
+ assert_array_equal (coll1 .get_facecolors ()[... , - 1 ], alpha )
939
+ assert_array_equal (coll2 .get_facecolors ()[... , - 1 ], alpha )
940
940
# Or provide 1-D alpha:
941
941
fig , (ax0 , ax1 ) = plt .subplots (2 )
942
- coll1 = ax0 .pcolormesh (x , y , z , alpha = alpha_flat )
942
+ coll1 = ax0 .pcolormesh (x , y , z , alpha = alpha )
943
943
coll2 = ax1 .pcolormesh (x , y , z )
944
- coll2 .set_alpha (alpha_flat )
944
+ coll2 .set_alpha (alpha )
945
945
plt .draw ()
946
- assert_array_equal (coll1 .get_facecolors ()[: , - 1 ], alpha_flat )
947
- assert_array_equal (coll2 .get_facecolors ()[: , - 1 ], alpha_flat )
946
+ assert_array_equal (coll1 .get_facecolors ()[... , - 1 ], alpha )
947
+ assert_array_equal (coll2 .get_facecolors ()[... , - 1 ], alpha )
948
948
949
949
950
950
def test_alpha_validation ():
@@ -992,7 +992,7 @@ def test_color_logic(pcfunc):
992
992
pc .update_scalarmappable () # This is called in draw().
993
993
# Define 2 reference "colors" here for multiple use.
994
994
face_default = mcolors .to_rgba_array (pc ._get_default_facecolor ())
995
- mapped = pc .get_cmap ()(pc .norm (z .ravel ()))
995
+ mapped = pc .get_cmap ()(pc .norm (z .ravel () if pcfunc == plt . pcolor else z ))
996
996
# GitHub issue #1302:
997
997
assert mcolors .same_color (pc .get_edgecolor (), 'red' )
998
998
# Check setting attributes after initialization:
@@ -1011,30 +1011,30 @@ def test_color_logic(pcfunc):
1011
1011
# Reset edgecolor to default.
1012
1012
pc .set_edgecolor (None )
1013
1013
pc .update_scalarmappable ()
1014
- assert mcolors . same_color (pc .get_edgecolor (), mapped )
1014
+ assert np . array_equal (pc .get_edgecolor (), mapped )
1015
1015
pc .set_facecolor (None ) # restore default for facecolor
1016
1016
pc .update_scalarmappable ()
1017
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1017
+ assert np . array_equal (pc .get_facecolor (), mapped )
1018
1018
assert mcolors .same_color (pc .get_edgecolor (), 'none' )
1019
1019
# Turn off colormapping entirely:
1020
1020
pc .set_array (None )
1021
1021
pc .update_scalarmappable ()
1022
1022
assert mcolors .same_color (pc .get_edgecolor (), 'none' )
1023
1023
assert mcolors .same_color (pc .get_facecolor (), face_default ) # not mapped
1024
1024
# Turn it back on by restoring the array (must be 1D!):
1025
- pc .set_array (z .ravel ())
1025
+ pc .set_array (z .ravel () if pcfunc == plt . pcolor else z )
1026
1026
pc .update_scalarmappable ()
1027
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1027
+ assert np . array_equal (pc .get_facecolor (), mapped )
1028
1028
assert mcolors .same_color (pc .get_edgecolor (), 'none' )
1029
1029
# Give color via tuple rather than string.
1030
1030
pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = (0 , 1 , 0 ))
1031
1031
pc .update_scalarmappable ()
1032
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1032
+ assert np . array_equal (pc .get_facecolor (), mapped )
1033
1033
assert mcolors .same_color (pc .get_edgecolor (), [[1 , 0 , 0 , 1 ]])
1034
1034
# Provide an RGB array; mapping overrides it.
1035
1035
pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = np .ones ((12 , 3 )))
1036
1036
pc .update_scalarmappable ()
1037
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1037
+ assert np . array_equal (pc .get_facecolor (), mapped )
1038
1038
assert mcolors .same_color (pc .get_edgecolor (), [[1 , 0 , 0 , 1 ]])
1039
1039
# Turn off the mapping.
1040
1040
pc .set_array (None )
@@ -1044,7 +1044,7 @@ def test_color_logic(pcfunc):
1044
1044
# And an RGBA array.
1045
1045
pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = np .ones ((12 , 4 )))
1046
1046
pc .update_scalarmappable ()
1047
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1047
+ assert np . array_equal (pc .get_facecolor (), mapped )
1048
1048
assert mcolors .same_color (pc .get_edgecolor (), [[1 , 0 , 0 , 1 ]])
1049
1049
# Turn off the mapping.
1050
1050
pc .set_array (None )
0 commit comments