14
14
from matplotlib import unpack_labeled_data
15
15
16
16
import matplotlib .cbook as cbook
17
- from matplotlib .cbook import mplDeprecation , STEP_LOOKUP_MAP
17
+ from matplotlib .cbook import (mplDeprecation , STEP_LOOKUP_MAP ,
18
+ iterable , is_string_like )
18
19
import matplotlib .collections as mcoll
19
20
import matplotlib .colors as mcolors
20
21
import matplotlib .contour as mcontour
43
44
44
45
rcParams = matplotlib .rcParams
45
46
46
- iterable = cbook .iterable
47
- is_string_like = cbook .is_string_like
48
- is_sequence_of_strings = cbook .is_sequence_of_strings
49
-
50
47
51
48
def _plot_args_replacer (args , data ):
52
49
if len (args ) == 1 :
@@ -1983,9 +1980,6 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
1983
1980
edgecolor = kwargs .pop ('edgecolor' , None )
1984
1981
linewidth = kwargs .pop ('linewidth' , None )
1985
1982
1986
- tick_label = kwargs .pop ('tick_label' , None )
1987
- label_ticks_flag = tick_label is not None
1988
-
1989
1983
# Because xerr and yerr will be passed to errorbar,
1990
1984
# most dimension checking and processing will be left
1991
1985
# to the errorbar method.
@@ -2001,6 +1995,7 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
2001
1995
orientation = kwargs .pop ('orientation' , 'vertical' )
2002
1996
log = kwargs .pop ('log' , False )
2003
1997
label = kwargs .pop ('label' , '' )
1998
+ tick_labels = kwargs .pop ('tick_label' , None )
2004
1999
2005
2000
def make_iterable (x ):
2006
2001
if not iterable (x ):
@@ -2016,7 +2011,6 @@ def make_iterable(x):
2016
2011
_bottom = bottom
2017
2012
bottom = make_iterable (bottom )
2018
2013
linewidth = make_iterable (linewidth )
2019
- tick_label = make_iterable (tick_label )
2020
2014
2021
2015
adjust_ylim = False
2022
2016
adjust_xlim = False
@@ -2061,8 +2055,6 @@ def make_iterable(x):
2061
2055
2062
2056
if len (linewidth ) < nbars :
2063
2057
linewidth *= nbars
2064
- if len (tick_label ) < nbars :
2065
- tick_label *= nbars
2066
2058
2067
2059
if color is None :
2068
2060
color = [None ] * nbars
@@ -2095,9 +2087,6 @@ def make_iterable(x):
2095
2087
if len (bottom ) != nbars :
2096
2088
raise ValueError ("incompatible sizes: argument 'bottom' "
2097
2089
"must be length %d or scalar" % nbars )
2098
- if len (tick_label ) != nbars :
2099
- raise ValueError ("incompatible sizes: argument 'tick_label' "
2100
- "must be length %d or string" % nbars )
2101
2090
2102
2091
patches = []
2103
2092
@@ -2193,9 +2182,18 @@ def make_iterable(x):
2193
2182
bar_container = BarContainer (patches , errorbar , label = label )
2194
2183
self .add_container (bar_container )
2195
2184
2196
- if label_ticks_flag :
2185
+ if tick_labels is not None :
2186
+ tick_labels = make_iterable (tick_labels )
2187
+ if isinstance (tick_labels , six .string_types ):
2188
+ tick_labels = [tick_labels ]
2189
+ if len (tick_labels ) == 1 :
2190
+ tick_labels *= nbars
2191
+ if len (tick_labels ) != nbars :
2192
+ raise ValueError ("incompatible sizes: argument 'tick_label' "
2193
+ "must be length %d or string" % nbars )
2194
+
2197
2195
tick_label_axis .set_ticks (tick_label_position )
2198
- tick_label_axis .set_ticklabels (tick_label )
2196
+ tick_label_axis .set_ticklabels (tick_labels )
2199
2197
2200
2198
return bar_container
2201
2199
0 commit comments