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
@@ -966,7 +968,7 @@ def bar(self, subset=None, align='left', axis=0,
966
968
If a str is passed, the color is the same for both
967
969
negative and positive numbers. If 2-tuple/list is used, the
968
970
first element is the color_negative and the second is the
969
- color_positive (eg: ['d65f5f', '5fba7d'])
971
+ color_positive (eg: ['# d65f5f', '# 5fba7d'])
970
972
width: float
971
973
A number between 0 or 100. The largest value will cover ``width``
972
974
percent of the cell's width
@@ -987,6 +989,15 @@ def bar(self, subset=None, align='left', axis=0,
987
989
988
990
if not (is_list_like (color )):
989
991
color = [color , color ]
992
+ elif len (color ) == 1 :
993
+ color = [color [0 ], color [0 ]]
994
+ elif len (color ) > 2 :
995
+ msg = ("Must pass `color` as string or a list-like"
996
+ " of length 2 [ `color_negative`, `color_positive`] "
997
+ "(eg: color=['#d65f5f', '#5fba7d'])\n "
998
+ "Only the first two list elements will be used here." )
999
+ warnings .warn (msg , UserWarning )
1000
+ color = [color [0 ], color [1 ]]
990
1001
991
1002
if align == 'left' :
992
1003
self .apply (self ._bar_left , subset = subset , axis = axis , color = color ,
0 commit comments