@@ -672,6 +672,11 @@ def test_can_plot_axis_size_one(self):
672672 if self .plotfunc .__name__ not in ('contour' , 'contourf' ):
673673 self .plotfunc (DataArray (np .ones ((1 , 1 ))))
674674
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+
675680 def test_viridis_cmap (self ):
676681 cmap_name = self .plotmethod (cmap = 'viridis' ).get_cmap ().name
677682 self .assertEqual ('viridis' , cmap_name )
@@ -1071,6 +1076,13 @@ def test_plot_rgb_image(self):
10711076 ).plot .imshow ()
10721077 self .assertEqual (0 , len (find_possible_colorbars ()))
10731078
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+
10741086 def test_plot_rgb_faceted (self ):
10751087 DataArray (
10761088 easy_array ((2 , 2 , 10 , 15 , 3 ), start = 0 ),
@@ -1093,6 +1105,16 @@ def test_warns_ambigious_dim(self):
10931105 arr .plot .imshow (rgb = 'band' )
10941106 arr .plot .imshow (x = 'x' , y = 'y' )
10951107
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+
10961118
10971119class TestFacetGrid (PlotTestCase ):
10981120
0 commit comments