diff --git a/src/args.jl b/src/args.jl index f5a8887a..a3bec516 100644 --- a/src/args.jl +++ b/src/args.jl @@ -993,15 +993,6 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) end end - # vline accesses the y argument but actually maps it to the x axis. - # Hence, we have to swap formatters - if get(plotattributes, :seriestype, :path) == :vline - xformatter = get(plotattributes, :xformatter, :auto) - yformatter = get(plotattributes, :yformatter, :auto) - plotattributes[:xformatter] = yformatter - plotattributes[:yformatter] = xformatter - end - # handle grid args common to all axes args = RecipesPipeline.pop_kw!(plotattributes, :grid, ()) for arg in wraptuple(args) @@ -1145,7 +1136,6 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) if st in (:boxplot, :violin, :density) && !isdefined(Main, :StatsPlots) @warn("seriestype $st has been moved to StatsPlots. To use: \`Pkg.add(\"StatsPlots\"); using StatsPlots\`") end - return end diff --git a/src/plot.jl b/src/plot.jl index e52ac499..9953acc7 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -164,6 +164,15 @@ end # a list of series KW dicts. # note: at entry, we only have those preprocessed args which were passed in... no default values yet function _plot!(plt::Plot, plotattributes, args) + # swap x and y for seriestypes that are x only + if get(plotattributes, :seriestype, :path) in + (:vline, :vspan, :histogram, :barhist, :stephist, :scatterhist) + if get(plotattributes, :orientation, :vertical) == :vertical + @assert length(args) == 1 + args = (args[1], []) + end + end + RecipesPipeline.recipe_pipeline!(plt, plotattributes, args) current(plt) _do_plot_show(plt, plt[:show]) diff --git a/src/recipes.jl b/src/recipes.jl index 468acf0d..9e2adfec 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -122,9 +122,10 @@ end @deps hline straightline @recipe function f(::Type{Val{:vline}}, x, y, z) + n = length(x) newx = vec(Float64[xi for i = 1:3, xi in x]) x := newx - y := y + y := repeat(Float64[1, 2, NaN], n) seriestype := :straightline () end diff --git a/src/shorthands.jl b/src/shorthands.jl index 59275610..89ac4e80 100644 --- a/src/shorthands.jl +++ b/src/shorthands.jl @@ -57,7 +57,7 @@ Plot a histogram. julia> histogram([1,2,1,1,4,3,8],bins=0:8) ``` """ -@one_arg_shorthands histogram +@shorthands histogram """ barhist(x) @@ -65,7 +65,7 @@ julia> histogram([1,2,1,1,4,3,8],bins=0:8) Make a histogram bar plot. See `histogram`. """ -@one_arg_shorthands barhist +@shorthands barhist """ stephist(x) @@ -74,7 +74,7 @@ Make a histogram bar plot. See `histogram`. Make a histogram step plot (bin counts are represented using horizontal lines instead of bars). See `histogram`. """ -@one_arg_shorthands stephist +@shorthands stephist """ scatterhist(x) @@ -83,7 +83,7 @@ instead of bars). See `histogram`. Make a histogram scatter plot (bin counts are represented using points instead of bars). See `histogram`. """ -@one_arg_shorthands scatterhist +@shorthands scatterhist """ histogram2d(x,y) @@ -190,9 +190,6 @@ julia> vline([-1,0,2]) ``` """ @shorthands vline -vline(x; kw...) = plot(x, repeat(Float64[1,2,NaN], length(x)); kw..., seriestype=:vline) -vline!(x; kw...) = plot!(x, repeat(Float64[1,2,NaN], length(x)); kw..., seriestype=:vline) -vline!(plt, x; kw...) = plot!(plt, x, repeat(Float64[1,2,NaN], length(x)); kw..., seriestype=:vline) """ hspan(y) @@ -223,9 +220,6 @@ julia> vspan(1:6) ``` """ @shorthands vspan -vspan(x; kw...) = plot(x, []; kw..., seriestype=:vspan) -vspan!(x; kw...) = plot!(x, []; kw..., seriestype=:vspan) -vspan!(plt, x; kw...) = plot!(plt, x, []; kw..., seriestype=:vspan) """ ohlc(x,y::Vector{OHLC}) diff --git a/test/runtests.jl b/test/runtests.jl index 13ae2868..5190f709 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,7 +12,7 @@ using Dates using RecipesBase include("test_axes.jl") -include("axis_letter.jl") +include("test_axis_letter.jl") include("test_recipes.jl") include("test_hdf5plots.jl") include("test_pgfplotsx.jl") diff --git a/test/axis_letter.jl b/test/test_axis_letter.jl similarity index 100% rename from test/axis_letter.jl rename to test/test_axis_letter.jl