@@ -1838,6 +1838,10 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
1838
1838
linewidth; If 0, don't draw edges.
1839
1839
default: None
1840
1840
1841
+ tick_label : string or array-like, optional
1842
+ the tick labels of the bars
1843
+ default: None
1844
+
1841
1845
xerr : scalar or array-like, optional
1842
1846
if not None, will be used to generate errorbar(s) on the bar chart
1843
1847
default: None
@@ -1908,6 +1912,9 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
1908
1912
edgecolor = kwargs .pop ('edgecolor' , None )
1909
1913
linewidth = kwargs .pop ('linewidth' , None )
1910
1914
1915
+ tick_label = kwargs .pop ('tick_label' , None )
1916
+ label_ticks_flag = tick_label is not None
1917
+
1911
1918
# Because xerr and yerr will be passed to errorbar,
1912
1919
# most dimension checking and processing will be left
1913
1920
# to the errorbar method.
@@ -1938,6 +1945,7 @@ def make_iterable(x):
1938
1945
_bottom = bottom
1939
1946
bottom = make_iterable (bottom )
1940
1947
linewidth = make_iterable (linewidth )
1948
+ tick_label = make_iterable (tick_label )
1941
1949
1942
1950
adjust_ylim = False
1943
1951
adjust_xlim = False
@@ -1956,6 +1964,9 @@ def make_iterable(x):
1956
1964
width *= nbars
1957
1965
if len (bottom ) == 1 :
1958
1966
bottom *= nbars
1967
+
1968
+ tick_label_axis = self .xaxis
1969
+ tick_label_position = left
1959
1970
elif orientation == 'horizontal' :
1960
1971
self ._process_unit_info (xdata = width , ydata = bottom , kwargs = kwargs )
1961
1972
if log :
@@ -1971,11 +1982,16 @@ def make_iterable(x):
1971
1982
left *= nbars
1972
1983
if len (height ) == 1 :
1973
1984
height *= nbars
1985
+
1986
+ tick_label_axis = self .yaxis
1987
+ tick_label_position = bottom
1974
1988
else :
1975
1989
raise ValueError ('invalid orientation: %s' % orientation )
1976
1990
1977
1991
if len (linewidth ) < nbars :
1978
1992
linewidth *= nbars
1993
+ if len (tick_label ) < nbars :
1994
+ tick_label *= nbars
1979
1995
1980
1996
if color is None :
1981
1997
color = [None ] * nbars
@@ -2008,6 +2024,9 @@ def make_iterable(x):
2008
2024
if len (bottom ) != nbars :
2009
2025
raise ValueError ("incompatible sizes: argument 'bottom' "
2010
2026
"must be length %d or scalar" % nbars )
2027
+ if len (tick_label ) != nbars :
2028
+ raise ValueError ("incompatible sizes: argument 'tick_label' "
2029
+ "must be length %d or string" % nbars )
2011
2030
2012
2031
patches = []
2013
2032
@@ -2103,6 +2122,10 @@ def make_iterable(x):
2103
2122
bar_container = BarContainer (patches , errorbar , label = label )
2104
2123
self .add_container (bar_container )
2105
2124
2125
+ if label_ticks_flag :
2126
+ tick_label_axis .set_ticks (tick_label_position )
2127
+ tick_label_axis .set_ticklabels (tick_label )
2128
+
2106
2129
return bar_container
2107
2130
2108
2131
@docstring .dedent_interpd
@@ -2148,6 +2171,9 @@ def barh(self, bottom, width, height=0.8, left=None, **kwargs):
2148
2171
width of bar edge(s). If None, use default
2149
2172
linewidth; If 0, don't draw edges.
2150
2173
2174
+ tick_label : string or array-like, optional, default: None
2175
+ the tick labels of the bars
2176
+
2151
2177
xerr : scalar or array-like, optional, default: None
2152
2178
if not None, will be used to generate errorbar(s) on the bar chart
2153
2179
0 commit comments