added _apply_recipe

This commit is contained in:
Thomas Breloff 2015-11-24 10:45:49 -05:00
parent cdb4901d91
commit cdc7920dff
3 changed files with 14 additions and 3 deletions

View File

@ -79,6 +79,9 @@ function plot!(plt::Plot, args...; kw...)
d = Dict(kw) d = Dict(kw)
preprocessArgs!(d) preprocessArgs!(d)
# for plotting recipes, swap out the args and update the parameter dictionary
args = _apply_recipe(d, args...; kw...)
dumpdict(d, "After plot! preprocessing") dumpdict(d, "After plot! preprocessing")
warnOnUnsupportedArgs(plt.backend, d) warnOnUnsupportedArgs(plt.backend, d)
@ -393,7 +396,7 @@ end
# special handling... xmin/xmax with function(s) # special handling... xmin/xmax with function(s)
function createKWargsList(plt::PlottingObject, f::FuncOrFuncs, xmin::Real, xmax::Real; kw...) function createKWargsList(plt::PlottingObject, f::FuncOrFuncs, xmin::Real, xmax::Real; kw...)
width = plt.plotargs[:size][1] width = get(plt.plotargs, :size, (100,))[1]
x = collect(linspace(xmin, xmax, width)) # we don't need more than the width x = collect(linspace(xmin, xmax, width)) # we don't need more than the width
createKWargsList(plt, x, f; kw...) createKWargsList(plt, x, f; kw...)
end end

View File

@ -14,6 +14,8 @@ plot(recipe::PlotRecipe, args...; kw...) = plot(getRecipeXY(recipe)..., args...;
plot!(recipe::PlotRecipe, args...; kw...) = plot!(getRecipeXY(recipe)..., args...; getRecipeArgs(recipe)..., kw...) plot!(recipe::PlotRecipe, args...; kw...) = plot!(getRecipeXY(recipe)..., args...; getRecipeArgs(recipe)..., kw...)
plot!(plt::Plot, recipe::PlotRecipe, args...; kw...) = plot!(getRecipeXY(recipe)..., args...; getRecipeArgs(recipe)..., kw...) plot!(plt::Plot, recipe::PlotRecipe, args...; kw...) = plot!(getRecipeXY(recipe)..., args...; getRecipeArgs(recipe)..., kw...)
# if it's not a recipe, just do nothing and return the args
_apply_recipe(d::Dict, args...; kw...) = args
# # ------------------------------------------------- # # -------------------------------------------------

View File

@ -220,9 +220,13 @@ end
# ------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------
function _preprocess_subplot(subplt::Subplot, d::Dict) function _preprocess_subplot(subplt::Subplot, d::Dict, args = ())
validateSubplotSupported() validateSubplotSupported()
preprocessArgs!(d) preprocessArgs!(d)
# for plotting recipes, swap out the args and update the parameter dictionary
args = _apply_recipe(d, args...; d...)
dumpdict(d, "After subplot! preprocessing") dumpdict(d, "After subplot! preprocessing")
# get the full plotargs, overriding any new settings # get the full plotargs, overriding any new settings
@ -246,6 +250,8 @@ function _preprocess_subplot(subplt::Subplot, d::Dict)
delete!(d, s) delete!(d, s)
end end
end end
args
end end
function _postprocess_subplot(subplt::Subplot, d::Dict) function _postprocess_subplot(subplt::Subplot, d::Dict)
@ -295,7 +301,7 @@ function subplot!(subplt::Subplot, args...; kw...)
# validateSubplotSupported() # validateSubplotSupported()
d = Dict(kw) d = Dict(kw)
_preprocess_subplot(subplt, d) args = _preprocess_subplot(subplt, d, args)
# create the underlying object (each backend will do this differently) # create the underlying object (each backend will do this differently)
# note: we call it once before doing the individual plots, and once after # note: we call it once before doing the individual plots, and once after