more subplot fixes
This commit is contained in:
parent
e08957f5ec
commit
1c556ade57
@ -475,10 +475,10 @@ function handlePlotColors(::PlottingPackage, d::Dict)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# converts a symbol or string into a colorant (Colors.RGB), and assigns a color automatically
|
# converts a symbol or string into a colorant (Colors.RGB), and assigns a color automatically
|
||||||
function getSeriesRGBColor(c, d::Dict, n::Int)
|
function getSeriesRGBColor(c, initargs::Dict, n::Int)
|
||||||
|
|
||||||
if c == :auto
|
if c == :auto
|
||||||
c = autopick(d[:color_palette], n)
|
c = autopick(initargs[:color_palette], n)
|
||||||
end
|
end
|
||||||
|
|
||||||
# c should now be a subtype of ColorScheme
|
# c should now be a subtype of ColorScheme
|
||||||
|
|||||||
@ -48,7 +48,9 @@ function plot(args...; kw...)
|
|||||||
preprocessArgs!(d)
|
preprocessArgs!(d)
|
||||||
dumpdict(d, "After plot preprocessing")
|
dumpdict(d, "After plot preprocessing")
|
||||||
|
|
||||||
plt = plot(pkg; getPlotArgs(pkg, d, 1)...) # create a new, blank plot
|
plotargs = getPlotArgs(pkg, d, 1)
|
||||||
|
dumpdict(plotargs, "Plot args")
|
||||||
|
plt = plot(pkg; plotargs...) # create a new, blank plot
|
||||||
|
|
||||||
delete!(d, :background_color)
|
delete!(d, :background_color)
|
||||||
plot!(plt, args...; d...) # add to it
|
plot!(plt, args...; d...) # add to it
|
||||||
@ -269,9 +271,9 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
|||||||
# build the series arg dict
|
# build the series arg dict
|
||||||
numUncounted = get(d, :numUncounted, 0)
|
numUncounted = get(d, :numUncounted, 0)
|
||||||
n = plt.n + i + numUncounted
|
n = plt.n + i + numUncounted
|
||||||
# dumpdict(d, "before getSeriesArgs")
|
dumpdict(d, "before getSeriesArgs")
|
||||||
d = getSeriesArgs(plt.backend, getinitargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
d = getSeriesArgs(plt.backend, getinitargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
||||||
# dumpdict(d, "after getSeriesArgs")
|
dumpdict(d, "after getSeriesArgs")
|
||||||
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
||||||
|
|
||||||
if haskey(d, :idxfilter)
|
if haskey(d, :idxfilter)
|
||||||
|
|||||||
@ -175,6 +175,7 @@ function subplot(args...; kw...)
|
|||||||
for i in 1:length(layout)
|
for i in 1:length(layout)
|
||||||
di = getPlotArgs(pkg, d, i)
|
di = getPlotArgs(pkg, d, i)
|
||||||
di[:subplot] = true
|
di[:subplot] = true
|
||||||
|
dumpdict(di, "Plot args (subplot $i)")
|
||||||
push!(plts, plot(pkg; di...))
|
push!(plts, plot(pkg; di...))
|
||||||
# push!(ds, getPlotArgs(pkg, d, i))
|
# push!(ds, getPlotArgs(pkg, d, i))
|
||||||
# ds[i][:subplot] = true
|
# ds[i][:subplot] = true
|
||||||
@ -234,6 +235,21 @@ function preprocessSubplot(subplt::Subplot, d::Dict)
|
|||||||
preprocessArgs!(d)
|
preprocessArgs!(d)
|
||||||
dumpdict(d, "After subplot! preprocessing")
|
dumpdict(d, "After subplot! preprocessing")
|
||||||
|
|
||||||
|
# get the full initargs, overriding any new settings
|
||||||
|
# TODO: subplt.initargs should probably be merged sooner and actually used
|
||||||
|
# for color selection, etc. (i.e. if we overwrite the subplot palettes to [:heat :rainbow])
|
||||||
|
# then we need to overwrite plt[1].initargs[:color_palette] to :heat before it's actually used
|
||||||
|
# for color selection!
|
||||||
|
|
||||||
|
# first merge the new args into the subplot's initargs. then process the plot args and merge
|
||||||
|
# those into the plot's initargs. (example... `palette = [:blues :reds]` goes into subplt.initargs,
|
||||||
|
# then the ColorGradient for :blues/:reds is merged into plot 1/2 initargs, which is then used for color selection)
|
||||||
|
merge!(subplt.initargs, d)
|
||||||
|
for i in 1:length(subplt.layout)
|
||||||
|
di = getPlotArgs(backend(), subplt.initargs, i)
|
||||||
|
merge!(subplt.plts[i].initargs, di)
|
||||||
|
end
|
||||||
|
|
||||||
# process links. TODO: extract to separate function
|
# process links. TODO: extract to separate function
|
||||||
for s in (:linkx, :linky, :linkfunc)
|
for s in (:linkx, :linky, :linkfunc)
|
||||||
if haskey(d, s)
|
if haskey(d, s)
|
||||||
@ -252,17 +268,23 @@ function postprocessSubplot(subplt::Subplot, d::Dict)
|
|||||||
# add title, axis labels, ticks, etc
|
# add title, axis labels, ticks, etc
|
||||||
for (i,plt) in enumerate(subplt.plts)
|
for (i,plt) in enumerate(subplt.plts)
|
||||||
|
|
||||||
# get the full initargs, overriding any new settings
|
# # # get the full initargs, overriding any new settings
|
||||||
di = copy(merge!(plt.initargs, d))
|
# # di = copy(merge(plt.initargs, d))
|
||||||
|
# di = copy(d)
|
||||||
|
|
||||||
|
# for (k,v) in di
|
||||||
|
# if typeof(v) <: AVec
|
||||||
|
# di[k] = v[mod1(i, length(v))]
|
||||||
|
# elseif typeof(v) <: AMat
|
||||||
|
# m = size(v,2)
|
||||||
|
# di[k] = (size(v,1) == 1 ? v[1, mod1(i, m)] : v[:, mod1(i, m)])
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
# di = merge!(plt.initargs, di)
|
||||||
|
|
||||||
|
di = plt.initargs
|
||||||
|
|
||||||
for (k,v) in di
|
|
||||||
if typeof(v) <: AVec
|
|
||||||
di[k] = v[mod1(i, length(v))]
|
|
||||||
elseif typeof(v) <: AMat
|
|
||||||
m = size(v,2)
|
|
||||||
di[k] = (size(v,1) == 1 ? v[1, mod1(i, m)] : v[:, mod1(i, m)])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
dumpdict(di, "Updating sp $i")
|
dumpdict(di, "Updating sp $i")
|
||||||
updatePlotItems(plt, di)
|
updatePlotItems(plt, di)
|
||||||
end
|
end
|
||||||
@ -328,6 +350,17 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
subplt.n += 1
|
subplt.n += 1
|
||||||
plt = getplot(subplt)
|
plt = getplot(subplt)
|
||||||
|
|
||||||
|
# # update the plot's initargs for things such as palettes, etc
|
||||||
|
# for (k,v) in subplt.initargs
|
||||||
|
# haskey(_plotDefaults, k) || continue
|
||||||
|
# if typeof(v) <: AVec
|
||||||
|
# plt.initargs[k] = v[mod1(i, length(v))]
|
||||||
|
# elseif typeof(v) <: AMat
|
||||||
|
# m = size(v,2)
|
||||||
|
# plt.initargs[k] = (size(v,1) == 1 ? v[1, mod1(i, m)] : v[:, mod1(i, m)])
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
# cleanup the dictionary that we pass into the plot! command
|
# cleanup the dictionary that we pass into the plot! command
|
||||||
di[:show] = false
|
di[:show] = false
|
||||||
di[:subplot] = true
|
di[:subplot] = true
|
||||||
@ -336,6 +369,7 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
delete!(di, k)
|
delete!(di, k)
|
||||||
end
|
end
|
||||||
dumpdict(di, "subplot! kwList $i")
|
dumpdict(di, "subplot! kwList $i")
|
||||||
|
dumpdict(plt.initargs, "plt.initargs before plotting")
|
||||||
|
|
||||||
_plot_from_subplot!(plt; di...)
|
_plot_from_subplot!(plt; di...)
|
||||||
end
|
end
|
||||||
@ -358,7 +392,7 @@ function _plot_from_subplot!(plt::Plot, args...; kw...)
|
|||||||
setTicksFromStringVector(d, d, :x, :xticks)
|
setTicksFromStringVector(d, d, :x, :xticks)
|
||||||
setTicksFromStringVector(d, d, :y, :yticks)
|
setTicksFromStringVector(d, d, :y, :yticks)
|
||||||
|
|
||||||
dumpdict(d, "Plot from subplot")
|
# dumpdict(d, "Plot from subplot")
|
||||||
plot!(plt.backend, plt; d...)
|
plot!(plt.backend, plt; d...)
|
||||||
|
|
||||||
addAnnotations(plt, d)
|
addAnnotations(plt, d)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user