move swap to _plot
This commit is contained in:
parent
255a32663e
commit
18c9edfe44
10
src/args.jl
10
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
|
||||
|
||||
|
||||
@ -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])
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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})
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user