@@ -904,13 +904,13 @@ def test_quadmesh_vmin_vmax():
904
904
norm = mpl .colors .Normalize (vmin = 0 , vmax = 1 )
905
905
coll = ax .pcolormesh ([[1 ]], cmap = cmap , norm = norm )
906
906
fig .canvas .draw ()
907
- assert np .array_equal (coll .get_facecolors ()[0 , :], cmap (norm (1 )))
907
+ assert np .array_equal (coll .get_facecolors ()[0 , 0 , :], cmap (norm (1 )))
908
908
909
909
# Change the vmin/vmax of the norm so that the color is from
910
910
# the bottom of the colormap now
911
911
norm .vmin , norm .vmax = 1 , 2
912
912
fig .canvas .draw ()
913
- assert np .array_equal (coll .get_facecolors ()[0 , :], cmap (norm (1 )))
913
+ assert np .array_equal (coll .get_facecolors ()[0 , 0 , :], cmap (norm (1 )))
914
914
915
915
916
916
def test_quadmesh_alpha_array ():
@@ -925,16 +925,16 @@ def test_quadmesh_alpha_array():
925
925
coll2 = ax1 .pcolormesh (x , y , z )
926
926
coll2 .set_alpha (alpha )
927
927
plt .draw ()
928
- assert_array_equal (coll1 .get_facecolors ()[: , - 1 ], alpha_flat )
929
- assert_array_equal (coll2 .get_facecolors ()[: , - 1 ], alpha_flat )
928
+ assert_array_equal (coll1 .get_facecolors ()[... , - 1 ], alpha )
929
+ assert_array_equal (coll2 .get_facecolors ()[... , - 1 ], alpha )
930
930
# Or provide 1-D alpha:
931
931
fig , (ax0 , ax1 ) = plt .subplots (2 )
932
- coll1 = ax0 .pcolormesh (x , y , z , alpha = alpha_flat )
932
+ coll1 = ax0 .pcolormesh (x , y , z , alpha = alpha )
933
933
coll2 = ax1 .pcolormesh (x , y , z )
934
- coll2 .set_alpha (alpha_flat )
934
+ coll2 .set_alpha (alpha )
935
935
plt .draw ()
936
- assert_array_equal (coll1 .get_facecolors ()[: , - 1 ], alpha_flat )
937
- assert_array_equal (coll2 .get_facecolors ()[: , - 1 ], alpha_flat )
936
+ assert_array_equal (coll1 .get_facecolors ()[... , - 1 ], alpha )
937
+ assert_array_equal (coll2 .get_facecolors ()[... , - 1 ], alpha )
938
938
939
939
940
940
def test_alpha_validation ():
@@ -982,7 +982,7 @@ def test_color_logic(pcfunc):
982
982
pc .update_scalarmappable () # This is called in draw().
983
983
# Define 2 reference "colors" here for multiple use.
984
984
face_default = mcolors .to_rgba_array (pc ._get_default_facecolor ())
985
- mapped = pc .get_cmap ()(pc .norm ((z .ravel ())))
985
+ mapped = pc .get_cmap ()(pc .norm ((z .ravel () if pcfunc == plt . pcolor else z )))
986
986
# GitHub issue #1302:
987
987
assert mcolors .same_color (pc .get_edgecolor (), 'red' )
988
988
# Check setting attributes after initialization:
@@ -1001,30 +1001,30 @@ def test_color_logic(pcfunc):
1001
1001
# Reset edgecolor to default.
1002
1002
pc .set_edgecolor (None )
1003
1003
pc .update_scalarmappable ()
1004
- assert mcolors . same_color (pc .get_edgecolor (), mapped )
1004
+ assert np . array_equal (pc .get_edgecolor (), mapped )
1005
1005
pc .set_facecolor (None ) # restore default for facecolor
1006
1006
pc .update_scalarmappable ()
1007
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1007
+ assert np . array_equal (pc .get_facecolor (), mapped )
1008
1008
assert mcolors .same_color (pc .get_edgecolor (), 'none' )
1009
1009
# Turn off colormapping entirely:
1010
1010
pc .set_array (None )
1011
1011
pc .update_scalarmappable ()
1012
1012
assert mcolors .same_color (pc .get_edgecolor (), 'none' )
1013
1013
assert mcolors .same_color (pc .get_facecolor (), face_default ) # not mapped
1014
1014
# Turn it back on by restoring the array (must be 1D!):
1015
- pc .set_array (z .ravel ())
1015
+ pc .set_array (z .ravel () if pcfunc == plt . pcolor else z )
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
# Give color via tuple rather than string.
1020
1020
pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = (0 , 1 , 0 ))
1021
1021
pc .update_scalarmappable ()
1022
- assert mcolors . same_color (pc .get_facecolor (), mapped )
1022
+ assert np . array_equal (pc .get_facecolor (), mapped )
1023
1023
assert mcolors .same_color (pc .get_edgecolor (), [[1 , 0 , 0 , 1 ]])
1024
1024
# Provide an RGB array; mapping overrides it.
1025
1025
pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = np .ones ((12 , 3 )))
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 (), [[1 , 0 , 0 , 1 ]])
1029
1029
# Turn off the mapping.
1030
1030
pc .set_array (None )
@@ -1034,7 +1034,7 @@ def test_color_logic(pcfunc):
1034
1034
# And an RGBA array.
1035
1035
pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = np .ones ((12 , 4 )))
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 )
0 commit comments