fix links to keep separate lims per row/column
This commit is contained in:
parent
3636860262
commit
c052e731f8
File diff suppressed because one or more lines are too long
@ -458,11 +458,10 @@ function preprocessArgs!(d::Dict)
|
|||||||
if isa(l, Bool)
|
if isa(l, Bool)
|
||||||
d[:linkx] = l
|
d[:linkx] = l
|
||||||
d[:linky] = l
|
d[:linky] = l
|
||||||
d[:linkfunc] = nothing
|
|
||||||
elseif isa(l, Function)
|
elseif isa(l, Function)
|
||||||
d[:linkx] = true
|
d[:linkx] = true
|
||||||
d[:linky] = true
|
d[:linky] = true
|
||||||
d[:linkfunc] = d[:link]
|
d[:linkfunc] = l
|
||||||
else
|
else
|
||||||
warn("Unhandled/invalid link $l. Should be a Bool or a function mapping (row,column) -> (linkx, linky), where linkx/y can be Bool or Void (nothing)")
|
warn("Unhandled/invalid link $l. Should be a Bool or a function mapping (row,column) -> (linkx, linky), where linkx/y can be Bool or Void (nothing)")
|
||||||
end
|
end
|
||||||
@ -505,7 +504,9 @@ end
|
|||||||
|
|
||||||
function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict)
|
function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict)
|
||||||
for k in sortedkeys(d)
|
for k in sortedkeys(d)
|
||||||
if !(k in supportedArgs(pkg)) && d[k] != default(k)
|
if (!(k in supportedArgs(pkg))
|
||||||
|
&& k != :subplot
|
||||||
|
&& d[k] != default(k))
|
||||||
warn("Keyword argument $k not supported with $pkg. Choose from: $(supportedArgs(pkg))")
|
warn("Keyword argument $k not supported with $pkg. Choose from: $(supportedArgs(pkg))")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -54,8 +54,8 @@ supportedArgs(::GadflyPackage) = [
|
|||||||
:xflip,
|
:xflip,
|
||||||
:yflip,
|
:yflip,
|
||||||
:z,
|
:z,
|
||||||
:linkx,
|
# :linkx,
|
||||||
:linky,
|
# :linky,
|
||||||
]
|
]
|
||||||
supportedAxes(::GadflyPackage) = [:auto, :left]
|
supportedAxes(::GadflyPackage) = [:auto, :left]
|
||||||
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
|
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
|
||||||
@ -421,7 +421,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function updateGadflyGuides(gplt, d::Dict)
|
function updateGadflyGuides(plt::Plot, d::Dict)
|
||||||
|
gplt = getGadflyContext(plt)
|
||||||
haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title])
|
haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title])
|
||||||
haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
|
haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
|
||||||
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
|
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
|
||||||
@ -429,14 +430,25 @@ function updateGadflyGuides(gplt, d::Dict)
|
|||||||
xlims = addGadflyLimitsScale(gplt, d, true)
|
xlims = addGadflyLimitsScale(gplt, d, true)
|
||||||
ylims = addGadflyLimitsScale(gplt, d, false)
|
ylims = addGadflyLimitsScale(gplt, d, false)
|
||||||
|
|
||||||
haskey(d, :xticks) && addGadflyTicksGuide(gplt, d[:xticks], true)
|
ticks = get(d, :xticks, :auto)
|
||||||
haskey(d, :yticks) && addGadflyTicksGuide(gplt, d[:yticks], false)
|
if ticks == :none
|
||||||
|
handleLinkInner(plt, true)
|
||||||
|
else
|
||||||
|
addGadflyTicksGuide(gplt, ticks, true)
|
||||||
|
end
|
||||||
|
ticks = get(d, :yticks, :auto)
|
||||||
|
if ticks == :none
|
||||||
|
handleLinkInner(plt, false)
|
||||||
|
else
|
||||||
|
addGadflyTicksGuide(gplt, ticks, false)
|
||||||
|
end
|
||||||
|
# haskey(d, :yticks) && addGadflyTicksGuide(gplt, d[:yticks], false)
|
||||||
|
|
||||||
updateGadflyAxisFlips(gplt, d, xlims, ylims)
|
updateGadflyAxisFlips(gplt, d, xlims, ylims)
|
||||||
end
|
end
|
||||||
|
|
||||||
function updatePlotItems(plt::Plot{GadflyPackage}, d::Dict)
|
function updatePlotItems(plt::Plot{GadflyPackage}, d::Dict)
|
||||||
updateGadflyGuides(plt.o, d)
|
updateGadflyGuides(plt, d)
|
||||||
end
|
end
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|||||||
@ -46,7 +46,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function updatePlotItems(plt::Plot{ImmersePackage}, d::Dict)
|
function updatePlotItems(plt::Plot{ImmersePackage}, d::Dict)
|
||||||
updateGadflyGuides(plt.o[2], d)
|
updateGadflyGuides(plt, d)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -56,8 +56,9 @@ supportedArgs(::PyPlotPackage) = [
|
|||||||
:xflip,
|
:xflip,
|
||||||
:yflip,
|
:yflip,
|
||||||
:z,
|
:z,
|
||||||
:linkx,
|
# :linkx,
|
||||||
:linky,
|
# :linky,
|
||||||
|
# :linkfunc,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotPackage) = _allAxes
|
supportedAxes(::PyPlotPackage) = _allAxes
|
||||||
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||||
|
|||||||
@ -77,6 +77,7 @@ function corrplot{T<:Real,S<:Real}(mat::AMat{T}, corrmat::AMat{S};
|
|||||||
if i==j
|
if i==j
|
||||||
# histogram on diagonal
|
# histogram on diagonal
|
||||||
plt = histogram(mat[:,i], c=:black)
|
plt = histogram(mat[:,i], c=:black)
|
||||||
|
i > 1 && plot!(yticks = :none)
|
||||||
else
|
else
|
||||||
# scatter plots off-diagonal, color determined by correlation
|
# scatter plots off-diagonal, color determined by correlation
|
||||||
c = RGBA(RGB(getColorZ(cgrad, corrmat[i,j])), 0.3)
|
c = RGBA(RGB(getColorZ(cgrad, corrmat[i,j])), 0.3)
|
||||||
|
|||||||
@ -116,26 +116,35 @@ function linkAxis(subplt::Subplot, isx::Bool)
|
|||||||
|
|
||||||
# collect the list of plots and the expanded limits for those plots that should be linked on this axis
|
# collect the list of plots and the expanded limits for those plots that should be linked on this axis
|
||||||
includedPlots = Any[]
|
includedPlots = Any[]
|
||||||
lims = [Inf, -Inf]
|
# lims = [Inf, -Inf]
|
||||||
|
lims = Dict{Int,Any}() # maps column to xlim
|
||||||
for (i,(r,c)) in enumerate(subplt.layout)
|
for (i,(r,c)) in enumerate(subplt.layout)
|
||||||
|
|
||||||
# shouldlink will be a bool or nothing. if nothing, then use linkx/y (which is true if we get to this code)
|
# shouldlink will be a bool or nothing. if nothing, then use linkx/y (which is true if we get to this code)
|
||||||
shouldlink = subplt.linkfunc(r,c)[isx ? 1 : 2]
|
shouldlink = subplt.linkfunc(r,c)[isx ? 1 : 2]
|
||||||
if shouldlink == nothing || shouldlink
|
if shouldlink == nothing || shouldlink
|
||||||
plt = subplt.plts[i]
|
plt = subplt.plts[i]
|
||||||
isinner = (isx && r < nrows(subplt.layout)) || (!isx && c > 1)
|
|
||||||
push!(includedPlots, (plt, isinner))
|
# if we don't have this
|
||||||
expandLimits!(lims, plt, isx)
|
k = isx ? c : r
|
||||||
|
if (firstone = !haskey(lims, k))
|
||||||
|
lims[k] = [Inf, -Inf]
|
||||||
|
end
|
||||||
|
|
||||||
|
isinner = (isx && r < nrows(subplt.layout)) || (!isx && !firstone)
|
||||||
|
push!(includedPlots, (plt, isinner, k))
|
||||||
|
|
||||||
|
expandLimits!(lims[k], plt, isx)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# do the axis adjustments
|
# do the axis adjustments
|
||||||
for (plt, isinner) in includedPlots
|
for (plt, isinner, k) in includedPlots
|
||||||
if isinner
|
if isinner
|
||||||
handleLinkInner(plt, isx)
|
handleLinkInner(plt, isx)
|
||||||
end
|
end
|
||||||
(isx ? xlims! : ylims!)(plt, lims...)
|
(isx ? xlims! : ylims!)(plt, lims[k]...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -237,11 +246,17 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
preprocessArgs!(d)
|
preprocessArgs!(d)
|
||||||
dumpdict(d, "After subplot! preprocessing")
|
dumpdict(d, "After subplot! preprocessing")
|
||||||
|
|
||||||
haskey(d, :linkx) && (subplt.linkx = d[:linkx])
|
for s in (:linkx, :linky, :linkfunc)
|
||||||
haskey(d, :linky) && (subplt.linky = d[:linky])
|
if haskey(d, s)
|
||||||
if get(d, :linkfunc, nothing) != nothing
|
setfield!(subplt, s, d[s])
|
||||||
subplt.linkfunc = d[:linkfunc]
|
delete!(d, s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
# haskey(d, :linkx) && (subplt.linkx = d[:linkx]; delete!(d, :linkx))
|
||||||
|
# haskey(d, :linky) && (subplt.linky = d[:linky])
|
||||||
|
# if haskey(d, :linkfunc)
|
||||||
|
# subplt.linkfunc = d[:linkfunc]
|
||||||
|
# end
|
||||||
|
|
||||||
kwList, xmeta, ymeta = createKWargsList(subplt, args...; d...)
|
kwList, xmeta, ymeta = createKWargsList(subplt, args...; d...)
|
||||||
|
|
||||||
@ -251,6 +266,7 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
subplt.n += 1
|
subplt.n += 1
|
||||||
plt = getplot(subplt) # get the Plot object where this series will be drawn
|
plt = getplot(subplt) # get the Plot object where this series will be drawn
|
||||||
di[:show] = false
|
di[:show] = false
|
||||||
|
di[:subplot] = true
|
||||||
dumpdict(di, "subplot! kwList $i")
|
dumpdict(di, "subplot! kwList $i")
|
||||||
plot!(plt; di...)
|
plot!(plt; di...)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user