You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bar() (and possibly other plots) should take an array of string labels for x axis #2516
I think this is an interesting idea. It would be great to have a basic implementation as a starting point to see how best this could be handled and what APIs (if any) it might break.
Since Axes.bar does not currently support arrays of strings for the first argument, this would be strictly new functionality and hence should not break any existing APIs.
My thinking was to simply add a few lines to bar() in _axes.py that do something like:
if all(isinstance(s, str) for s in left):
labels = left
left = range(1, len(left)+1)
align = 'center'
else:
labels = None
and then further below in the bar() function do something like
if labels != None:
if orientation == 'horizontal':
self.xaxis.set_ticks(left)
self.xaxis.set_ticklabels(labels)
else:
self.yaxis.set_ticks(left)
self.yaxis.set_ticklabels(labels)
(Though I'm not much of a Python hacker. I mainly use matplotlib from the Julia via the PyPlot.jl package.)
Activity
mdboom commentedon Oct 14, 2013
I think this is an interesting idea. It would be great to have a basic implementation as a starting point to see how best this could be handled and what APIs (if any) it might break.
stevengj commentedon Oct 14, 2013
Since
Axes.bardoes not currently support arrays of strings for the first argument, this would be strictly new functionality and hence should not break any existing APIs.My thinking was to simply add a few lines to
bar()in_axes.pythat do something like:and then further below in the
bar()function do something like(Though I'm not much of a Python hacker. I mainly use matplotlib from the Julia via the PyPlot.jl package.)
support string labels in bar (work around matplotlib/matplotlib#2516)