From fb60c244f629b294a6fc4bbb6c6b298a57d7244f Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Thu, 19 May 2016 17:34:37 -0400 Subject: [PATCH] bar_width and bar_edges keywords; small fixes --- src/args.jl | 4 +++- src/backends/pyplot.jl | 7 ++++--- src/plot.jl | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/args.jl b/src/args.jl index 4cb18d57..1e14cee5 100644 --- a/src/args.jl +++ b/src/args.jl @@ -146,6 +146,8 @@ _series_defaults[:marker_z] = nothing # value for color scale _series_defaults[:levels] = 15 _series_defaults[:orientation] = :vertical _series_defaults[:bar_position] = :overlay # for bar plots and histograms: could also be stack (stack up) or dodge (side by side) +_series_defaults[:bar_width] = 0.8 +_series_defaults[:bar_edges] = false _series_defaults[:xerror] = nothing _series_defaults[:yerror] = nothing _series_defaults[:ribbon] = nothing @@ -957,7 +959,7 @@ function _update_subplot_args(plt::Plot, sp::Subplot, d_in::KW, subplot_index::I else spargs[axissym] = Axis(letter) end - + # grab magic args (for example `xaxis = (:flip, :log)`) args = wraptuple(get(d_in, axissym, ())) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 7dfcc491..79d0f9c5 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -16,7 +16,7 @@ supportedArgs(::PyPlotBackend) = [ :markershape, :markercolor, :markersize, :markeralpha, :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :fillrange, :fillcolor, :fillalpha, - :bins, + :bins, :bar_width, :bar_edges, :n, :nc, :nr, :layout, :smooth, :title, :windowtitle, :show, :size, @@ -94,6 +94,7 @@ end getPyPlotColor(c::Colorant, α=nothing) = map(f->float(f(convertColor(c,α))), (red, green, blue, alpha)) getPyPlotColor(cvec::ColorVector, α=nothing) = map(getPyPlotColor, convertColor(cvec, α).v) getPyPlotColor(scheme::ColorScheme, α=nothing) = getPyPlotColor(convertColor(getColor(scheme), α)) +getPyPlotColor(vec::AVec, α=nothing) = map(c->getPyPlotColor(c,α), vec) getPyPlotColor(c, α=nothing) = getPyPlotColor(convertColor(c, α)) function getPyPlotColorMap(c::ColorGradient, α=nothing) @@ -662,14 +663,14 @@ function _add_series(plt::Plot{PyPlotBackend}, series::Series) end if st == :bar - extrakw[isvertical(d) ? :width : :height] = 0.9 + extrakw[isvertical(d) ? :width : :height] = d[:bar_width] handle = ax[isvertical(d) ? :bar : :barh](x, y; label = d[:label], zorder = plt.n, color = pyfillcolor(d), edgecolor = pylinecolor(d), linewidth = d[:linewidth], - align = "center", + align = d[:bar_edges] ? "edge" : "center", extrakw... )[1] push!(handles, handle) diff --git a/src/plot.jl b/src/plot.jl index 541c7a03..be6e02fa 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -179,6 +179,7 @@ function _apply_series_recipe(plt::Plot, d::KW) end # add the series! + warnOnUnsupportedArgs(plt.backend, d) warnOnUnsupported(plt.backend, d) series = Series(d) push!(plt.series_list, series) @@ -269,7 +270,6 @@ function _plot!(plt::Plot, d::KW, args...) end # check that the backend will support the command and add it to the list - warnOnUnsupportedArgs(plt.backend, kw) warnOnUnsupportedScales(plt.backend, kw) push!(kw_list, kw)