@@ -1146,6 +1146,53 @@ def test_series_grid_settings(self):
1146
1146
self ._check_grid_settings (Series ([1 ,2 ,3 ]),
1147
1147
plotting ._series_kinds + plotting ._common_kinds )
1148
1148
1149
+ @slow
1150
+ def test_standard_colors (self ):
1151
+ for c in ['r' , 'red' , 'green' , '#FF0000' ]:
1152
+ result = plotting ._get_standard_colors (1 , color = c )
1153
+ self .assertEqual (result , [c ])
1154
+
1155
+ result = plotting ._get_standard_colors (1 , color = [c ])
1156
+ self .assertEqual (result , [c ])
1157
+
1158
+ result = plotting ._get_standard_colors (3 , color = c )
1159
+ self .assertEqual (result , [c ] * 3 )
1160
+
1161
+ result = plotting ._get_standard_colors (3 , color = [c ])
1162
+ self .assertEqual (result , [c ] * 3 )
1163
+
1164
+ @slow
1165
+ def test_standard_colors_all (self ):
1166
+ import matplotlib .colors as colors
1167
+
1168
+ # multiple colors like mediumaquamarine
1169
+ for c in colors .cnames :
1170
+ result = plotting ._get_standard_colors (num_colors = 1 , color = c )
1171
+ self .assertEqual (result , [c ])
1172
+
1173
+ result = plotting ._get_standard_colors (num_colors = 1 , color = [c ])
1174
+ self .assertEqual (result , [c ])
1175
+
1176
+ result = plotting ._get_standard_colors (num_colors = 3 , color = c )
1177
+ self .assertEqual (result , [c ] * 3 )
1178
+
1179
+ result = plotting ._get_standard_colors (num_colors = 3 , color = [c ])
1180
+ self .assertEqual (result , [c ] * 3 )
1181
+
1182
+ # single letter colors like k
1183
+ for c in colors .ColorConverter .colors :
1184
+ result = plotting ._get_standard_colors (num_colors = 1 , color = c )
1185
+ self .assertEqual (result , [c ])
1186
+
1187
+ result = plotting ._get_standard_colors (num_colors = 1 , color = [c ])
1188
+ self .assertEqual (result , [c ])
1189
+
1190
+ result = plotting ._get_standard_colors (num_colors = 3 , color = c )
1191
+ self .assertEqual (result , [c ] * 3 )
1192
+
1193
+ result = plotting ._get_standard_colors (num_colors = 3 , color = [c ])
1194
+ self .assertEqual (result , [c ] * 3 )
1195
+
1149
1196
1150
1197
@tm .mplskip
1151
1198
class TestDataFramePlots (TestPlotBase ):
@@ -1736,7 +1783,6 @@ def test_bar_colors(self):
1736
1783
1737
1784
default_colors = plt .rcParams .get ('axes.color_cycle' )
1738
1785
1739
-
1740
1786
df = DataFrame (randn (5 , 5 ))
1741
1787
ax = df .plot (kind = 'bar' )
1742
1788
self ._check_colors (ax .patches [::5 ], facecolors = default_colors [:5 ])
@@ -1762,6 +1808,11 @@ def test_bar_colors(self):
1762
1808
1763
1809
ax = df .ix [:, [0 ]].plot (kind = 'bar' , color = 'DodgerBlue' )
1764
1810
self ._check_colors ([ax .patches [0 ]], facecolors = ['DodgerBlue' ])
1811
+ tm .close ()
1812
+
1813
+ ax = df .plot (kind = 'bar' , color = 'green' )
1814
+ self ._check_colors (ax .patches [::5 ], facecolors = ['green' ] * 5 )
1815
+ tm .close ()
1765
1816
1766
1817
@slow
1767
1818
def test_bar_linewidth (self ):
@@ -2897,6 +2948,10 @@ def test_line_colors(self):
2897
2948
ax = df .ix [:, [0 ]].plot (color = 'DodgerBlue' )
2898
2949
self ._check_colors (ax .lines , linecolors = ['DodgerBlue' ])
2899
2950
2951
+ ax = df .plot (color = 'red' )
2952
+ self ._check_colors (ax .get_lines (), linecolors = ['red' ] * 5 )
2953
+ tm .close ()
2954
+
2900
2955
@slow
2901
2956
def test_area_colors (self ):
2902
2957
from matplotlib import cm
@@ -2972,6 +3027,10 @@ def test_hist_colors(self):
2972
3027
ax = df .ix [:, [0 ]].plot (kind = 'hist' , color = 'DodgerBlue' )
2973
3028
self ._check_colors ([ax .patches [0 ]], facecolors = ['DodgerBlue' ])
2974
3029
3030
+ ax = df .plot (kind = 'hist' , color = 'green' )
3031
+ self ._check_colors (ax .patches [::10 ], facecolors = ['green' ] * 5 )
3032
+ tm .close ()
3033
+
2975
3034
@slow
2976
3035
def test_kde_colors (self ):
2977
3036
tm ._skip_if_no_scipy ()
0 commit comments