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)
|
||||
d[:linkx] = l
|
||||
d[:linky] = l
|
||||
d[:linkfunc] = nothing
|
||||
elseif isa(l, Function)
|
||||
d[:linkx] = true
|
||||
d[:linky] = true
|
||||
d[:linkfunc] = d[:link]
|
||||
d[:linkfunc] = l
|
||||
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)")
|
||||
end
|
||||
@ -505,7 +504,9 @@ end
|
||||
|
||||
function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict)
|
||||
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))")
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,8 +54,8 @@ supportedArgs(::GadflyPackage) = [
|
||||
:xflip,
|
||||
:yflip,
|
||||
:z,
|
||||
:linkx,
|
||||
:linky,
|
||||
# :linkx,
|
||||
# :linky,
|
||||
]
|
||||
supportedAxes(::GadflyPackage) = [:auto, :left]
|
||||
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, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
|
||||
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
|
||||
@ -429,14 +430,25 @@ function updateGadflyGuides(gplt, d::Dict)
|
||||
xlims = addGadflyLimitsScale(gplt, d, true)
|
||||
ylims = addGadflyLimitsScale(gplt, d, false)
|
||||
|
||||
haskey(d, :xticks) && addGadflyTicksGuide(gplt, d[:xticks], true)
|
||||
haskey(d, :yticks) && addGadflyTicksGuide(gplt, d[:yticks], false)
|
||||
ticks = get(d, :xticks, :auto)
|
||||
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)
|
||||
end
|
||||
|
||||
function updatePlotItems(plt::Plot{GadflyPackage}, d::Dict)
|
||||
updateGadflyGuides(plt.o, d)
|
||||
updateGadflyGuides(plt, d)
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
@ -46,7 +46,7 @@ end
|
||||
|
||||
|
||||
function updatePlotItems(plt::Plot{ImmersePackage}, d::Dict)
|
||||
updateGadflyGuides(plt.o[2], d)
|
||||
updateGadflyGuides(plt, d)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -56,8 +56,9 @@ supportedArgs(::PyPlotPackage) = [
|
||||
:xflip,
|
||||
:yflip,
|
||||
:z,
|
||||
:linkx,
|
||||
:linky,
|
||||
# :linkx,
|
||||
# :linky,
|
||||
# :linkfunc,
|
||||
]
|
||||
supportedAxes(::PyPlotPackage) = _allAxes
|
||||
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
|
||||
# histogram on diagonal
|
||||
plt = histogram(mat[:,i], c=:black)
|
||||
i > 1 && plot!(yticks = :none)
|
||||
else
|
||||
# scatter plots off-diagonal, color determined by correlation
|
||||
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
|
||||
includedPlots = Any[]
|
||||
lims = [Inf, -Inf]
|
||||
# lims = [Inf, -Inf]
|
||||
lims = Dict{Int,Any}() # maps column to xlim
|
||||
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 = subplt.linkfunc(r,c)[isx ? 1 : 2]
|
||||
if shouldlink == nothing || shouldlink
|
||||
plt = subplt.plts[i]
|
||||
isinner = (isx && r < nrows(subplt.layout)) || (!isx && c > 1)
|
||||
push!(includedPlots, (plt, isinner))
|
||||
expandLimits!(lims, plt, isx)
|
||||
|
||||
# if we don't have this
|
||||
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
|
||||
|
||||
# do the axis adjustments
|
||||
for (plt, isinner) in includedPlots
|
||||
for (plt, isinner, k) in includedPlots
|
||||
if isinner
|
||||
handleLinkInner(plt, isx)
|
||||
end
|
||||
(isx ? xlims! : ylims!)(plt, lims...)
|
||||
(isx ? xlims! : ylims!)(plt, lims[k]...)
|
||||
end
|
||||
end
|
||||
|
||||
@ -237,11 +246,17 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
preprocessArgs!(d)
|
||||
dumpdict(d, "After subplot! preprocessing")
|
||||
|
||||
haskey(d, :linkx) && (subplt.linkx = d[:linkx])
|
||||
haskey(d, :linky) && (subplt.linky = d[:linky])
|
||||
if get(d, :linkfunc, nothing) != nothing
|
||||
subplt.linkfunc = d[:linkfunc]
|
||||
for s in (:linkx, :linky, :linkfunc)
|
||||
if haskey(d, s)
|
||||
setfield!(subplt, s, d[s])
|
||||
delete!(d, s)
|
||||
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...)
|
||||
|
||||
@ -251,6 +266,7 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
subplt.n += 1
|
||||
plt = getplot(subplt) # get the Plot object where this series will be drawn
|
||||
di[:show] = false
|
||||
di[:subplot] = true
|
||||
dumpdict(di, "subplot! kwList $i")
|
||||
plot!(plt; di...)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user