diff --git a/src/examples.jl b/src/examples.jl index 71c41a8c..e9155d0e 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -52,7 +52,7 @@ the `z` argument to turn on series gradients. [:(begin y = rand(100) plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6) -scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,stroke(1,:green)), ms=10*abs.(y.-0.5).+4, +scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,Plots.stroke(1,:green)), ms=10*abs.(y.-0.5).+4, lab="grad") end)] ), @@ -66,6 +66,7 @@ the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!` `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` """, [:(begin +using Statistics y = rand(20,3) plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), leg=false) @@ -85,8 +86,8 @@ yaxis!("YLABEL", :log10) PlotExample("Images", "Plot an image. y-axis is set to flipped", [:(begin - import FileIO - img = FileIO.load(Pkg.dir("PlotReferenceImages","Plots","pyplot","0.7.0","ref1.png")) + import FileIO, PlotReferenceImages + img = FileIO.load(joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots","pyplot","0.7.0","ref1.png")) plot(img) end)] ), @@ -102,7 +103,7 @@ series. """, [:(begin ys = Vector[rand(10), rand(20)] - plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,stroke(3,:gray))) + plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,Plots.stroke(3,:gray))) end)] ), @@ -202,7 +203,8 @@ plot(Plots.fakedata(100,10), layout=4, palette=[:grays :blues :heat :lightrainbo PlotExample("", "", [:(begin - Random.srand(111) + using Random + Random.seed!(111) plot!(Plots.fakedata(100,10)) end)] ), @@ -295,7 +297,7 @@ PlotExample("3D", x = ts .* map(cos,ts) y = 0.1ts .* map(sin,ts) z = 1:n - plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,stroke(0)), leg=false, cbar=true, w=5) + plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,Plots.stroke(0)), leg=false, cbar=true, w=5) plot!(zeros(n),zeros(n),1:n, w=10) end)] ), @@ -382,8 +384,9 @@ various different nonzero values, a colorbar is added. The colorbar can be disab `legend = nothing`. """, [:(begin - a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) - b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) + using SparseArrays + a = spdiagm(0 => ones(50), 1 => ones(49), -1 => ones(49), 10 => ones(40), -10 => ones(40)) + b = spdiagm(0 => 1:50, 1 => 1:49, -1 => 1:49, 10 => 1:40, -10 => 1:40) plot(spy(a), spy(b), title = ["Unique nonzeros" "Different nonzeros"]) end)] ), @@ -411,7 +414,7 @@ attribute. The default framestyle is `:axes`. scatter(fill(randn(10), 6), fill(randn(10), 6), framestyle = [:box :semi :origin :zerolines :grid :none], title = [":box" ":semi" ":origin" ":zerolines" ":grid" ":none"], - color = RowVector(1:6), layout = 6, label = "", markerstrokewidth = 0, + color = permutedims(1:6), layout = 6, label = "", markerstrokewidth = 0, ticks = -2:2) end)] ), diff --git a/test/add_packages.jl b/test/add_packages.jl index 655ec4d6..260707d3 100644 --- a/test/add_packages.jl +++ b/test/add_packages.jl @@ -3,7 +3,7 @@ using Pkg # need this to use Conda # ENV["PYTHON"] = "" -Pkg.add([ +to_add = [ PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"), # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), PackageSpec(name="PlotUtils", rev="master"), @@ -14,7 +14,18 @@ Pkg.add([ # PackageSpec(name="VisualRegressionTests", rev="master"), # PackageSpec("PyPlot"), # PackageSpec("InspectDR"), -]) +] + +if isinteractive() + append!(to_add, [ + PackageSpec(name="FileIO"), + PackageSpec(name="ImageMagick"), + PackageSpec(name="UnicodePlots"), + PackageSpec(name="VisualRegressionTests"), + ]) +end + +Pkg.add(to_add) Pkg.build("ImageMagick") # Pkg.build("GR") diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 92841b92..1145f272 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -32,7 +32,7 @@ default(size=(500,300)) const _current_plots_version = v"0.17.4" -function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], eps = 1e-2) +function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2) Plots._debugMode.on = debug example = Plots._examples[idx] @info("Testing plot: $pkg:$idx:$(example.header)") @@ -89,7 +89,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # the test vtest = VisualTest(func, reffn, idx) - test_images(vtest, popup=popup, sigma=sigma, eps=eps, newfn = newfn) + test_images(vtest, popup=popup, sigma=sigma, tol=tol, newfn = newfn) end function image_comparison_facts(pkg::Symbol; @@ -97,11 +97,11 @@ function image_comparison_facts(pkg::Symbol; only = nothing, # limit to these examples (int index) debug = false, # print debug information? sigma = [1,1], # number of pixels to "blur" - eps = 1e-2) # acceptable error (percent) + tol = 1e-2) # acceptable error (percent) for i in 1:length(Plots._examples) i in skip && continue if only == nothing || i in only - @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success == true + @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true end end end diff --git a/test/runtests.jl b/test/runtests.jl index 61d0e049..543b8ea3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,7 +6,7 @@ include("imgcomp.jl") # don't actually show the plots Random.seed!(1234) default(show=false, reuse=true) -img_eps = isinteractive() ? 1e-2 : 10e-2 +img_tol = isinteractive() ? 1e-2 : 10e-2 @testset "GR" begin ENV["PLOTS_TEST"] = "true" @@ -14,7 +14,7 @@ img_eps = isinteractive() ? 1e-2 : 10e-2 @test gr() == Plots.GRBackend() @test backend() == Plots.GRBackend() - image_comparison_facts(:gr, eps=img_eps, skip = [25, 30]) + image_comparison_facts(:gr, tol=img_tol, skip = [25, 30]) end @@ -22,7 +22,7 @@ end # @test pyplot() == Plots.PyPlotBackend() # @test backend() == Plots.PyPlotBackend() # -# image_comparison_facts(:pyplot, eps=img_eps) +# image_comparison_facts(:pyplot, tol=img_tol) #end @testset "UnicodePlots" begin @@ -47,7 +47,7 @@ end # 27, # (polar plots) takes very long / not working # 31, # animation (skipped for speed) # ], -# eps=img_eps) +# tol=img_tol) # end # end @@ -71,7 +71,7 @@ end # 28, # heatmap not defined # 31, # animation # ], -# eps=img_eps) +# tol=img_tol) # end @@ -80,7 +80,7 @@ end # @test backend() == Plots.PlotlyBackend() # # # # until png generation is reliable on OSX, just test on linux -# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) +# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], tol=img_tol) # end @@ -89,7 +89,7 @@ end # @test backend() == Plots.ImmerseBackend() # # # as long as we can plot anything without error, it should be the same as Gadfly -# image_comparison_facts(:immerse, only=[1], eps=img_eps) +# image_comparison_facts(:immerse, only=[1], tol=img_tol) # end @@ -98,7 +98,7 @@ end # @test backend() == Plots.PlotlyJSBackend() # # # as long as we can plot anything without error, it should be the same as Plotly -# image_comparison_facts(:plotlyjs, only=[1], eps=img_eps) +# image_comparison_facts(:plotlyjs, only=[1], tol=img_tol) # end @@ -111,7 +111,7 @@ end # @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) # @test plot!(rand(10,3), rand(10,3)) == not(nothing) # -# image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps) +# image_comparison_facts(:gadfly, skip=[4,6,23,24,27], tol=img_tol) # end