From 824dbe994879d01533f69c23bd1352b3d5a5e041 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Fri, 28 Jan 2022 11:30:42 +0100 Subject: [PATCH] UnicodePlots: use more `extra_kwargs` (#4080) --- src/backends.jl | 3 --- src/backends/unicodeplots.jl | 13 +++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/backends.jl b/src/backends.jl index 5911f90a..3ed11b5b 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -974,9 +974,6 @@ const _unicodeplots_scale = [:identity, :ln, :log2, :log10] # Additional constants const _up_colormap = Ref(:none) -const _up_canvas = Ref(:auto) -const _up_border = Ref(:auto) -const _up_fix_ar = Ref(true) # ------------------------------------------------------------------------------ # hdf5 diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index 66caa1b7..776d0744 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -34,13 +34,13 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend}) # create a plot window with xlim/ylim set, # but the X/Y vectors are outside the bounds - canvas = if (up_c = _up_canvas[]) == :auto + canvas = if (up_c = get(sp[:extra_kwargs], :canvas, :auto)) == :auto isijulia() ? :ascii : :braille else up_c end - border = if (up_b = _up_border[]) == :auto + border = if (up_b = get(sp[:extra_kwargs], :border, :auto)) == :auto isijulia() ? :ascii : :solid else up_b @@ -50,9 +50,9 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend}) width = has_layout && isempty(series_list(sp)) ? 0 : UnicodePlots.DEFAULT_WIDTH[] height = UnicodePlots.DEFAULT_HEIGHT[] + blend = get(sp[:extra_kwargs], :blend, true) grid = xaxis[:grid] && yaxis[:grid] quiver = contour = false - blend = true for series in series_list(sp) st = series[:seriestype] blend &= get(series[:extra_kwargs], :blend, true) @@ -65,7 +65,7 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend}) grid = false end end - grid &= !contour && !quiver + grid &= !(quiver || contour) blend &= !(quiver || contour) kw = ( @@ -136,10 +136,11 @@ function addUnicodeSeries!( end # special handling (src/interface) + fix_ar = get(series[:extra_kwargs], :fix_ar, true) if st === :histogram2d return UnicodePlots.densityplot(x, y; kw...) elseif st === :spy - return UnicodePlots.spy(series[:z].surf; fix_ar = _up_fix_ar[], kw...) + return UnicodePlots.spy(series[:z].surf; fix_ar = fix_ar, kw...) elseif st in (:contour, :heatmap) kw = ( kw..., @@ -158,7 +159,7 @@ function addUnicodeSeries!( levels = series[:levels], ) elseif st === :heatmap - return UnicodePlots.heatmap(series[:z].surf; fix_ar = _up_fix_ar[], kw...) + return UnicodePlots.heatmap(series[:z].surf; fix_ar = fix_ar, kw...) # zlim = collect(axis_limits(sp, :z)) end end