@@ -2047,7 +2047,6 @@ def test_no_legend(self):
20472047 df = DataFrame (np .random .rand (3 , 3 ), columns = ["a" , "b" , "c" ])
20482048
20492049 for kind in kinds :
2050-
20512050 ax = df .plot (kind = kind , legend = False )
20522051 self ._check_legend_labels (ax , visible = False )
20532052
@@ -2067,8 +2066,8 @@ def test_style_by_column(self):
20672066 fig .clf ()
20682067 fig .add_subplot (111 )
20692068 ax = df .plot (style = markers )
2070- for i , l in enumerate (ax .get_lines ()[: len (markers )]):
2071- assert l .get_marker () == markers [i ]
2069+ for idx , line in enumerate (ax .get_lines ()[: len (markers )]):
2070+ assert line .get_marker () == markers [idx ]
20722071
20732072 @pytest .mark .slow
20742073 def test_line_label_none (self ):
@@ -2141,8 +2140,7 @@ def test_line_colors_and_styles_subplots(self):
21412140
21422141 axes = df .plot (subplots = True )
21432142 for ax , c in zip (axes , list (default_colors )):
2144- c = [c ]
2145- self ._check_colors (ax .get_lines (), linecolors = c )
2143+ self ._check_colors (ax .get_lines (), linecolors = [c ])
21462144 tm .close ()
21472145
21482146 # single color char
@@ -2584,32 +2582,30 @@ def test_hexbin_with_c(self):
25842582 assert len (ax .collections ) == 1
25852583
25862584 @pytest .mark .slow
2587- def test_hexbin_cmap (self ):
2585+ @pytest .mark .parametrize (
2586+ "kwargs, expected" ,
2587+ [
2588+ ({}, "BuGn" ), # default cmap
2589+ ({"colormap" : "cubehelix" }, "cubehelix" ),
2590+ ({"cmap" : "YlGn" }, "YlGn" ),
2591+ ],
2592+ )
2593+ def test_hexbin_cmap (self , kwargs , expected ):
25882594 df = self .hexbin_df
2589-
2590- # Default to BuGn
2591- ax = df .plot .hexbin (x = "A" , y = "B" )
2592- assert ax .collections [0 ].cmap .name == "BuGn"
2593-
2594- cm = "cubehelix"
2595- ax = df .plot .hexbin (x = "A" , y = "B" , colormap = cm )
2596- assert ax .collections [0 ].cmap .name == cm
2595+ ax = df .plot .hexbin (x = "A" , y = "B" , ** kwargs )
2596+ assert ax .collections [0 ].cmap .name == expected
25972597
25982598 @pytest .mark .slow
25992599 def test_no_color_bar (self ):
26002600 df = self .hexbin_df
2601-
26022601 ax = df .plot .hexbin (x = "A" , y = "B" , colorbar = None )
26032602 assert ax .collections [0 ].colorbar is None
26042603
26052604 @pytest .mark .slow
2606- def test_allow_cmap (self ):
2605+ def test_mixing_cmap_and_colormap_raises (self ):
26072606 df = self .hexbin_df
2608-
2609- ax = df .plot .hexbin (x = "A" , y = "B" , cmap = "YlGn" )
2610- assert ax .collections [0 ].cmap .name == "YlGn"
2611-
2612- with pytest .raises (TypeError ):
2607+ msg = "Only specify one of `cmap` and `colormap`"
2608+ with pytest .raises (TypeError , match = msg ):
26132609 df .plot .hexbin (x = "A" , y = "B" , cmap = "YlGn" , colormap = "BuGn" )
26142610
26152611 @pytest .mark .slow
@@ -2671,12 +2667,13 @@ def test_pie_df_nan(self):
26712667 expected [i ] = ""
26722668 result = [x .get_text () for x in ax .texts ]
26732669 assert result == expected
2670+
26742671 # legend labels
26752672 # NaN's not included in legend with subplots
26762673 # see https://github.com/pandas-dev/pandas/issues/8390
2677- assert [x .get_text () for x in ax .get_legend ().get_texts ()] == base_expected [
2678- : i
2679- ] + base_expected [ i + 1 :]
2674+ result_labels = [x .get_text () for x in ax .get_legend ().get_texts ()]
2675+ expected_labels = base_expected [: i ] + base_expected [ i + 1 :]
2676+ assert result_labels == expected_labels
26802677
26812678 @pytest .mark .slow
26822679 def test_errorbar_plot (self ):
@@ -2839,7 +2836,6 @@ def test_errorbar_timeseries(self, kind):
28392836 self ._check_has_errorbars (axes , xerr = 0 , yerr = 1 )
28402837
28412838 def test_errorbar_asymmetrical (self ):
2842-
28432839 np .random .seed (0 )
28442840 err = np .random .rand (3 , 2 , 5 )
28452841
0 commit comments