From 61a2d962c070e5a20e934d729f10ce81ce811e19 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 24 Jun 2018 11:03:56 +0200 Subject: [PATCH 1/2] widen most seriestypes including logscales --- src/arg_desc.jl | 3 ++- src/args.jl | 1 + src/axes.jl | 20 +++++++++++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/arg_desc.jl b/src/arg_desc.jl index d5a6436d..56e3719d 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -140,5 +140,6 @@ const _arg_desc = KW( :gridstyle => "Symbol. Style of the grid lines. Choose from $(_allStyles)", :gridlinewidth => "Number. Width of the grid lines (in pixels)", :tick_direction => "Symbol. Direction of the ticks. `:in` or `:out`", -:showaxis => "Bool, Symbol or String. Show the axis. `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:off`" +:showaxis => "Bool, Symbol or String. Show the axis. `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:off`", +:widen => "Bool. Widen the axis limits by a small factor to avoid cut-off markers and lines at the borders. Defaults to `true`.", ) diff --git a/src/args.jl b/src/args.jl index bd6670dc..671485d0 100644 --- a/src/args.jl +++ b/src/args.jl @@ -382,6 +382,7 @@ const _axis_defaults = KW( :gridlinewidth => 0.5, :tick_direction => :in, :showaxis => true, + :widen => true, ) const _suppress_warnings = Set{Symbol}([ diff --git a/src/axes.jl b/src/axes.jl index f32d0ade..1410b28b 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -418,21 +418,23 @@ end # ------------------------------------------------------------------------- # push the limits out slightly -function widen(lmin, lmax) - span = lmax - lmin +function widen(lmin, lmax, scale = :identity) + f, invf = scalefunc(scale), invscalefunc(scale) + span = f(lmax) - f(lmin) # eps = NaNMath.max(1e-16, min(1e-2span, 1e-10)) eps = NaNMath.max(1e-16, 0.03span) - lmin-eps, lmax+eps + invf(f(lmin)-eps), invf(f(lmax)+eps) end -# figure out if widening is a good idea. if there's a scale set it's too tricky, -# so lazy out and don't widen +# figure out if widening is a good idea. +const _widen_seriestypes = (:line, :path, :steppre, :steppost, :sticks, :scatter, :barbins, :barhist, :histogram, :scatterbins, :scatterhist, :stepbins, :stephist, :bins2d, :histogram2d, :bar, :shape, :path3d, :scatter3d) + function default_should_widen(axis::Axis) should_widen = false - if axis[:scale] == :identity && !is_2tuple(axis[:lims]) + if !is_2tuple(axis[:lims]) for sp in axis.sps for series in series_list(sp) - if series.d[:seriestype] in (:scatter,) || series.d[:markershape] != :none + if series.d[:seriestype] in _widen_seriestypes should_widen = true end end @@ -476,8 +478,8 @@ function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis) else amin, amax end - elseif should_widen - widen(amin, amax) + elseif should_widen && axis[:widen] + widen(amin, amax, axis[:scale]) elseif lims == :round round_limits(amin,amax) else From 12c9a8e6c3d4f9a462de9b555c4cbd52b6956395 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 24 Jun 2018 19:01:06 +0200 Subject: [PATCH 2/2] plots_heatmap --- src/recipes.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/recipes.jl b/src/recipes.jl index 2393f6a8..dfb1fd54 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -413,6 +413,7 @@ end z := nothing seriestype := :shape label := "" + widen --> false () end @deps plots_heatmap shape