@@ -672,6 +672,11 @@ def test_can_plot_axis_size_one(self):
672
672
if self .plotfunc .__name__ not in ('contour' , 'contourf' ):
673
673
self .plotfunc (DataArray (np .ones ((1 , 1 ))))
674
674
675
+ def test_disallows_rgb_arg (self ):
676
+ with pytest .raises (ValueError ):
677
+ # Always invalid for most plots. Invalid for imshow with 2D data.
678
+ self .plotfunc (DataArray (np .ones ((2 , 2 ))), rgb = 'not None' )
679
+
675
680
def test_viridis_cmap (self ):
676
681
cmap_name = self .plotmethod (cmap = 'viridis' ).get_cmap ().name
677
682
self .assertEqual ('viridis' , cmap_name )
@@ -1071,6 +1076,13 @@ def test_plot_rgb_image(self):
1071
1076
).plot .imshow ()
1072
1077
self .assertEqual (0 , len (find_possible_colorbars ()))
1073
1078
1079
+ def test_plot_rgb_image_explicit (self ):
1080
+ DataArray (
1081
+ easy_array ((10 , 15 , 3 ), start = 0 ),
1082
+ dims = ['y' , 'x' , 'band' ],
1083
+ ).plot .imshow (y = 'y' , x = 'x' , rgb = 'band' )
1084
+ self .assertEqual (0 , len (find_possible_colorbars ()))
1085
+
1074
1086
def test_plot_rgb_faceted (self ):
1075
1087
DataArray (
1076
1088
easy_array ((2 , 2 , 10 , 15 , 3 ), start = 0 ),
@@ -1093,6 +1105,16 @@ def test_warns_ambigious_dim(self):
1093
1105
arr .plot .imshow (rgb = 'band' )
1094
1106
arr .plot .imshow (x = 'x' , y = 'y' )
1095
1107
1108
+ def test_rgb_errors_too_many_dims (self ):
1109
+ arr = DataArray (easy_array ((3 , 3 , 3 , 3 )), dims = ['y' , 'x' , 'z' , 'band' ])
1110
+ with pytest .raises (ValueError ):
1111
+ arr .plot .imshow (rgb = 'band' )
1112
+
1113
+ def test_rgb_errors_bad_dim_sizes (self ):
1114
+ arr = DataArray (easy_array ((5 , 5 , 5 )), dims = ['y' , 'x' , 'band' ])
1115
+ with pytest .raises (ValueError ):
1116
+ arr .plot .imshow (rgb = 'band' )
1117
+
1096
1118
1097
1119
class TestFacetGrid (PlotTestCase ):
1098
1120
0 commit comments