working on recipes overhaul
This commit is contained in:
parent
cf9b60660d
commit
d491b29037
148
src/plot.jl
148
src/plot.jl
@ -74,6 +74,13 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
_plot!(plt, d, args...)
|
_plot!(plt, d, args...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _add_plotargs!(plt::Plot, d::KW)
|
||||||
|
for k in keys(_plotDefaults)
|
||||||
|
if haskey(d, k)
|
||||||
|
plt.plotargs[k] = pop!(d, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# this is the core plotting function. recursively apply recipes to build
|
# this is the core plotting function. recursively apply recipes to build
|
||||||
# a list of series KW dicts.
|
# a list of series KW dicts.
|
||||||
@ -102,6 +109,10 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
series_list = RecipesBase.apply_recipe(next_series.d, next_series.args...)
|
series_list = RecipesBase.apply_recipe(next_series.d, next_series.args...)
|
||||||
for series in series_list
|
for series in series_list
|
||||||
if isempty(series.args)
|
if isempty(series.args)
|
||||||
|
# apply markershape_to_add and then warn if there's anything left unsupported
|
||||||
|
_add_markershape(series.d)
|
||||||
|
warnOnUnsupportedArgs(plt.backend, series.d)
|
||||||
|
warnOnUnsupportedScales(plt.backend, series.d)
|
||||||
push!(kw_list, series.d)
|
push!(kw_list, series.d)
|
||||||
else
|
else
|
||||||
push!(still_to_process, series)
|
push!(still_to_process, series)
|
||||||
@ -109,12 +120,7 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# dumpdict(d, "After plot! preprocessing")
|
# !!! note: at this point, kw_list is fully decomposed into individual series... one KW per series !!!
|
||||||
|
|
||||||
# apply markershape_to_add and then warn if there's anything left unsupported
|
|
||||||
_add_markershape(d)
|
|
||||||
warnOnUnsupportedArgs(plt.backend, d)
|
|
||||||
warnOnUnsupportedScales(plt.backend, d)
|
|
||||||
|
|
||||||
|
|
||||||
# # # grouping
|
# # # grouping
|
||||||
@ -129,13 +135,16 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# merge plot args
|
# merge plot args
|
||||||
if !haskey(d, :subplot)
|
if !haskey(d, :subplot)
|
||||||
# merge the plot args from the recipes, then update the plot colors
|
# merge the plot args from the recipes, then update the plot colors
|
||||||
for k in keys(_plotDefaults)
|
for kw in vcat(kw_list, d)
|
||||||
for kw in kw_list
|
_add_plotargs!(plt, kw)
|
||||||
if haskey(kw, k)
|
|
||||||
plt.plotargs[k] = kw[k]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
# for k in keys(_plotDefaults)
|
||||||
|
# for kw in kw_list
|
||||||
|
# if haskey(kw, k)
|
||||||
|
# plt.plotargs[k] = pop!(kw, k)
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
# merge!(plt.plotargs, d)
|
# merge!(plt.plotargs, d)
|
||||||
handlePlotColors(plt.backend, plt.plotargs)
|
handlePlotColors(plt.backend, plt.plotargs)
|
||||||
end
|
end
|
||||||
@ -187,6 +196,7 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# _update_plot_pos_size(plt, d) # this is only used for Qwt... can we remove?
|
# _update_plot_pos_size(plt, d) # this is only used for Qwt... can we remove?
|
||||||
|
|
||||||
current(plt)
|
current(plt)
|
||||||
|
|
||||||
# note: lets ignore the show param and effectively use the semicolon at the end of the REPL statement
|
# note: lets ignore the show param and effectively use the semicolon at the end of the REPL statement
|
||||||
@ -226,63 +236,63 @@ function _replace_linewidth(d::KW)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# no grouping
|
# # no grouping
|
||||||
function _add_series(plt::Plot, d::KW, args...;
|
# function _add_series(plt::Plot, d::KW, args...;
|
||||||
idxfilter = nothing,
|
# idxfilter = nothing,
|
||||||
grouplabel = "")
|
# grouplabel = "")
|
||||||
|
#
|
||||||
# get the list of dictionaries, one per series
|
# # get the list of dictionaries, one per series
|
||||||
dumpdict(d, "before process_inputs")
|
# dumpdict(d, "before process_inputs")
|
||||||
process_inputs(plt, d, args...)
|
# process_inputs(plt, d, args...)
|
||||||
dumpdict(d, "after process_inputs")
|
# dumpdict(d, "after process_inputs")
|
||||||
|
#
|
||||||
if idxfilter != nothing
|
# if idxfilter != nothing
|
||||||
# add the group name as the label if there isn't one passed in
|
# # add the group name as the label if there isn't one passed in
|
||||||
get!(d, :label, grouplabel)
|
# get!(d, :label, grouplabel)
|
||||||
# filter the data
|
# # filter the data
|
||||||
filter_data!(d, idxfilter)
|
# filter_data!(d, idxfilter)
|
||||||
end
|
# end
|
||||||
# dumpdict(d,"",true)
|
# # dumpdict(d,"",true)
|
||||||
|
#
|
||||||
seriesArgList, xmeta, ymeta = build_series_args(plt, d) #, idxfilter)
|
# seriesArgList, xmeta, ymeta = build_series_args(plt, d) #, idxfilter)
|
||||||
# seriesArgList, xmeta, ymeta = build_series_args(plt, groupargs..., args...; d...)
|
# # seriesArgList, xmeta, ymeta = build_series_args(plt, groupargs..., args...; d...)
|
||||||
|
#
|
||||||
# # if we were able to extract guide information from the series inputs, then update the plot
|
# # # if we were able to extract guide information from the series inputs, then update the plot
|
||||||
# # @show xmeta, ymeta
|
# # # @show xmeta, ymeta
|
||||||
# updateDictWithMeta(d, plt.plotargs, xmeta, true)
|
# # updateDictWithMeta(d, plt.plotargs, xmeta, true)
|
||||||
# updateDictWithMeta(d, plt.plotargs, ymeta, false)
|
# # updateDictWithMeta(d, plt.plotargs, ymeta, false)
|
||||||
|
#
|
||||||
|
#
|
||||||
# function _add_series(plt::Plot, ds::)
|
# # function _add_series(plt::Plot, ds::)
|
||||||
# now we can plot the series
|
# # now we can plot the series
|
||||||
for (i,di) in enumerate(seriesArgList)
|
# for (i,di) in enumerate(seriesArgList)
|
||||||
plt.n += 1
|
# plt.n += 1
|
||||||
|
#
|
||||||
if !stringsSupported() && di[:linetype] != :pie
|
# if !stringsSupported() && di[:linetype] != :pie
|
||||||
setTicksFromStringVector(plt, d, di, "x")
|
# setTicksFromStringVector(plt, d, di, "x")
|
||||||
setTicksFromStringVector(plt, d, di, "y")
|
# setTicksFromStringVector(plt, d, di, "y")
|
||||||
setTicksFromStringVector(plt, d, di, "z")
|
# setTicksFromStringVector(plt, d, di, "z")
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# remove plot args
|
# # remove plot args
|
||||||
for k in keys(_plotDefaults)
|
# for k in keys(_plotDefaults)
|
||||||
delete!(di, k)
|
# delete!(di, k)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# merge in plotarg_overrides
|
# # merge in plotarg_overrides
|
||||||
plotarg_overrides = pop!(di, :plotarg_overrides, nothing)
|
# plotarg_overrides = pop!(di, :plotarg_overrides, nothing)
|
||||||
if plotarg_overrides != nothing
|
# if plotarg_overrides != nothing
|
||||||
merge!(plt.plotargs, plotarg_overrides)
|
# merge!(plt.plotargs, plotarg_overrides)
|
||||||
end
|
# end
|
||||||
# dumpdict(plt.plotargs, "pargs", true)
|
# # dumpdict(plt.plotargs, "pargs", true)
|
||||||
|
#
|
||||||
dumpdict(di, "Series $i")
|
# dumpdict(di, "Series $i")
|
||||||
|
#
|
||||||
_replace_linewidth(di)
|
# _replace_linewidth(di)
|
||||||
|
#
|
||||||
_add_series(plt.backend, plt, di)
|
# _add_series(plt.backend, plt, di)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,9 @@ end
|
|||||||
for i in 1:max(mx, my, mz)
|
for i in 1:max(mx, my, mz)
|
||||||
# add a new series
|
# add a new series
|
||||||
di = copy(d)
|
di = copy(d)
|
||||||
di[:x], di[:y], di[:z] = compute_xyz(xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)])
|
xi, yi, zi = xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)]
|
||||||
|
@show i, typeof((xi, yi, zi))
|
||||||
|
di[:x], di[:y], di[:z] = compute_xyz(xi, yi, zi)
|
||||||
|
|
||||||
# handle fillrange
|
# handle fillrange
|
||||||
fr = fillranges[mod1(i,mf)]
|
fr = fillranges[mod1(i,mf)]
|
||||||
@ -153,7 +155,7 @@ end
|
|||||||
n,m = size(mat)
|
n,m = size(mat)
|
||||||
1:n, 1:m, Surface(mat)
|
1:n, 1:m, Surface(mat)
|
||||||
else
|
else
|
||||||
nothing, nothing, mat
|
nothing, mat, nothing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user