19
19
20
20
from pandas .types .common import is_float , is_string_like , is_list_like
21
21
22
+ import warnings
23
+
22
24
import numpy as np
23
25
import pandas as pd
24
26
from pandas .compat import range
@@ -971,7 +973,7 @@ def bar(self, subset=None, align='left', axis=0,
971
973
If a str is passed, the color is the same for both
972
974
negative and positive numbers. If 2-tuple/list is used, the
973
975
first element is the color_negative and the second is the
974
- color_positive (eg: ['d65f5f', '5fba7d'])
976
+ color_positive (eg: ['# d65f5f', '# 5fba7d'])
975
977
width: float
976
978
A number between 0 or 100. The largest value will cover ``width``
977
979
percent of the cell's width
@@ -992,6 +994,15 @@ def bar(self, subset=None, align='left', axis=0,
992
994
993
995
if not (is_list_like (color )):
994
996
color = [color , color ]
997
+ elif len (color ) == 1 :
998
+ color = [color [0 ], color [0 ]]
999
+ elif len (color ) > 2 :
1000
+ msg = ("Must pass `color` as string or a list-like"
1001
+ " of length 2 [ `color_negative`, `color_positive`] "
1002
+ "(eg: color=['#d65f5f', '#5fba7d'])\n "
1003
+ "Only the first two list elements will be used here." )
1004
+ warnings .warn (msg , UserWarning )
1005
+ color = [color [0 ], color [1 ]]
995
1006
996
1007
if align == 'left' :
997
1008
self .apply (self ._bar_left , subset = subset , axis = axis , color = color ,
0 commit comments