From a919fe59d3f24d3a9f39dc62e163a3846cede608 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 16 Feb 2022 22:05:50 +0100 Subject: [PATCH] Center `:image` axes ticks (#4088) --- src/axes.jl | 1 - src/examples.jl | 4 ---- src/recipes.jl | 5 +++-- test/runtests.jl | 18 +++++++++--------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/axes.jl b/src/axes.jl index f2298292..974f34b8 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -677,7 +677,6 @@ end # we return (continuous_value, discrete_index) function discrete_value!(axis::Axis, dv) cv_idx = get(axis[:discrete_map], dv, -1) - # @show axis[:discrete_map], axis[:discrete_values], dv if cv_idx == -1 ex = axis[:extrema] cv = NaNMath.max(0.5, ex.emax + 1.0) diff --git a/src/examples.jl b/src/examples.jl index 9178d10b..60e5d0df 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -849,7 +849,6 @@ const _examples = PlotExample[ [ quote begin - using Plots default( titlefont = (20, "times"), legendfontsize = 18, @@ -1071,7 +1070,6 @@ const _examples = PlotExample[ "", [ quote - using Plots using TestImages img = testimage("lighthouse") @@ -1092,8 +1090,6 @@ const _examples = PlotExample[ "3d quiver", "", [quote - using Plots - ϕs = range(-π, π, length = 50) θs = range(0, π, length = 25) θqs = range(1, π - 1, length = 25) diff --git a/src/recipes.jl b/src/recipes.jl index 3cd07e02..e6dbb545 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1380,7 +1380,8 @@ function clamp_greys!(mat::AMat{<:Gray}) end @recipe function f(mat::AMat{<:Gray}) - n, m = axes(mat) + n, m = map(a -> range(0.5, stop = a.stop + 0.5), axes(mat)) + if is_seriestype_supported(:image) seriestype := :image yflip --> true @@ -1398,7 +1399,7 @@ end # images - colors @recipe function f(mat::AMat{T}) where {T<:Colorant} - n, m = axes(mat) + n, m = map(a -> range(0.5, stop = a.stop + 0.5), axes(mat)) if is_seriestype_supported(:image) seriestype := :image diff --git a/test/runtests.jl b/test/runtests.jl index a5e1cf61..eb27269a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -249,15 +249,6 @@ end @test show(io, p) isa Nothing end - @testset "PlotlyJS" begin - @test plotlyjs() == Plots.PlotlyJSBackend() - @test backend() == Plots.PlotlyJSBackend() - - p = plot(rand(10)) - @test p isa Plots.Plot - @test_broken display(p) isa Nothing - end - @testset "GR" begin ENV["PLOTS_TEST"] = "true" ENV["GKSwstype"] = "100" @@ -274,4 +265,13 @@ end ) end end + + @testset "PlotlyJS" begin + @test plotlyjs() == Plots.PlotlyJSBackend() + @test backend() == Plots.PlotlyJSBackend() + + p = plot(rand(10)) + @test p isa Plots.Plot + @test_broken display(p) isa Nothing + end end