@@ -2047,7 +2047,6 @@ def test_no_legend(self):
2047
2047
df = DataFrame (np .random .rand (3 , 3 ), columns = ["a" , "b" , "c" ])
2048
2048
2049
2049
for kind in kinds :
2050
-
2051
2050
ax = df .plot (kind = kind , legend = False )
2052
2051
self ._check_legend_labels (ax , visible = False )
2053
2052
@@ -2067,8 +2066,8 @@ def test_style_by_column(self):
2067
2066
fig .clf ()
2068
2067
fig .add_subplot (111 )
2069
2068
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 ]
2072
2071
2073
2072
@pytest .mark .slow
2074
2073
def test_line_label_none (self ):
@@ -2141,8 +2140,7 @@ def test_line_colors_and_styles_subplots(self):
2141
2140
2142
2141
axes = df .plot (subplots = True )
2143
2142
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 ])
2146
2144
tm .close ()
2147
2145
2148
2146
# single color char
@@ -2584,32 +2582,30 @@ def test_hexbin_with_c(self):
2584
2582
assert len (ax .collections ) == 1
2585
2583
2586
2584
@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 ):
2588
2594
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
2597
2597
2598
2598
@pytest .mark .slow
2599
2599
def test_no_color_bar (self ):
2600
2600
df = self .hexbin_df
2601
-
2602
2601
ax = df .plot .hexbin (x = "A" , y = "B" , colorbar = None )
2603
2602
assert ax .collections [0 ].colorbar is None
2604
2603
2605
2604
@pytest .mark .slow
2606
- def test_allow_cmap (self ):
2605
+ def test_mixing_cmap_and_colormap_raises (self ):
2607
2606
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 ):
2613
2609
df .plot .hexbin (x = "A" , y = "B" , cmap = "YlGn" , colormap = "BuGn" )
2614
2610
2615
2611
@pytest .mark .slow
@@ -2671,12 +2667,13 @@ def test_pie_df_nan(self):
2671
2667
expected [i ] = ""
2672
2668
result = [x .get_text () for x in ax .texts ]
2673
2669
assert result == expected
2670
+
2674
2671
# legend labels
2675
2672
# NaN's not included in legend with subplots
2676
2673
# 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
2680
2677
2681
2678
@pytest .mark .slow
2682
2679
def test_errorbar_plot (self ):
@@ -2839,7 +2836,6 @@ def test_errorbar_timeseries(self, kind):
2839
2836
self ._check_has_errorbars (axes , xerr = 0 , yerr = 1 )
2840
2837
2841
2838
def test_errorbar_asymmetrical (self ):
2842
-
2843
2839
np .random .seed (0 )
2844
2840
err = np .random .rand (3 , 2 , 5 )
2845
2841
0 commit comments