Skip to content

Commit 3217abe

Browse files
committed
support string labels in bar (work around matplotlib/matplotlib#2516)
1 parent ec2a991 commit 3217abe

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎src/PyPlot.jl‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,22 @@ fill(x::AbstractArray,y::AbstractArray, args...; kws...) =
246246

247247
include("colormaps.jl")
248248

249+
###########################################################################
250+
# Support array of string labels in bar chart
251+
252+
function bar{T<:String}(x::AbstractVector{T}, y; kws...)
253+
xi = 1:length(x)
254+
if !any(kw -> kw[1] == :align, kws)
255+
push!(kws, (:align, "center"))
256+
end
257+
p = bar(xi, y; kws...)
258+
ax = any(kw -> kw[1] == :orientation && lowercase(kw[2]) == "horizontal",
259+
kws) ? gca()["yaxis"] : gca()["xaxis"]
260+
ax[:set_ticks](xi)
261+
ax[:set_ticklabels](x)
262+
return p
263+
end
264+
249265
###########################################################################
250266
# Include mplot3d for 3d plotting.
251267

0 commit comments

Comments
 (0)