From 5bb9aceaac40d9105581c577fbdfa85f1309c99b Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Sun, 12 Jun 2016 13:06:15 -0400 Subject: [PATCH] pyplot log scale threshold fix; imgcomp fix to filter out higher versions --- src/backends/pyplot.jl | 27 +++++++++++++++++++-------- test/imgcomp.jl | 12 +++++++----- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 67367542..365857d4 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -915,21 +915,32 @@ function py_set_ticks(ax, ticks, letter) end end -function py_set_scale(ax, scaleType::Symbol, letter) - scaleType in supported_scales() || return warn("Unhandled scale value in pyplot: $scaleType") +function py_compute_axis_minval(axis::Axis) + minval = 1.0 + sp = axis.sp + for series in series_list(axis.sp) + minval = min(minval, minimum(abs(series.d[axis[:letter]]))) + end + minval +end + +function py_set_scale(ax, axis::Axis) + scale = axis[:scale] + letter = axis[:letter] + scale in supported_scales() || return warn("Unhandled scale value in pyplot: $scale") func = ax[Symbol("set_", letter, "scale")] kw = KW() - arg = if scaleType == :identity + arg = if scale == :identity "linear" else - kw[Symbol(:base,letter)] = if scaleType == :ln + kw[Symbol(:base,letter)] = if scale == :ln e - elseif scaleType == :log2 + elseif scale == :log2 2 - elseif scaleType == :log10 + elseif scale == :log10 10 end - # kw[Symbol(:linthresh,letter)] = 1e-16 + kw[Symbol(:linthresh,letter)] = max(1e-16, py_compute_axis_minval(axis)) "symlog" end func(arg; kw...) @@ -998,7 +1009,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) axissym = Symbol(letter, :axis) axis = sp[axissym] haskey(ax, axissym) || continue - py_set_scale(ax, axis[:scale], letter) + py_set_scale(ax, axis) py_set_lims(ax, axis) py_set_ticks(ax, get_ticks(axis), letter) ax[Symbol("set_", letter, "label")](axis[:guide]) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 252949ab..71839547 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -45,17 +45,19 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # @show refdir fn G versions = map(fn -> VersionNumber(split(fn,"/")[end]), G) versions = reverse(sort(versions)) + versions = filter(v -> v <= _current_plots_version, versions) # @show refdir fn versions - reffn = nothing newdir = joinpath(refdir, string(_current_plots_version)) newfn = joinpath(newdir, fn) + + # figure out which reference file we should compare to, by finding the highest versioned file + reffn = nothing for v in versions - try - tmpfn = joinpath(refdir, string(v), fn) - # @show "trying", tmpfn - f = open(tmpfn) + tmpfn = joinpath(refdir, string(v), fn) + if isfile(tmpfn) reffn = tmpfn + break end end