From baac9a0578e96a9c8b9d02b6788be46d0b0d2adf Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 26 May 2020 11:37:13 -0500 Subject: [PATCH 01/11] Remove explicit Revise.track from atsign-require blocks (#2734) * Remove explicit Revise.track from atsign-require blocks Since Revise 2.4, it has no longer been necessary to explicitly call Revise.track, as Revise handles this internally. Also related: https://github.com/timholy/Revise.jl/pull/487, which checks to see whether Revise.track was called via atsign-require and if so return without doing anything. * Bump Requires [compat] to 1 --- Project.toml | 2 +- src/init.jl | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 54a30260..b947b346 100644 --- a/Project.toml +++ b/Project.toml @@ -46,7 +46,7 @@ PlotUtils = "1" RecipesBase = "1" RecipesPipeline = "0.1.7" Reexport = "0.2" -Requires = "0.5, 1" +Requires = "1" Showoff = "0.3.1" StatsBase = "0.32, 0.33" julia = "1" diff --git a/src/init.jl b/src/init.jl index 624e78f6..3f731395 100644 --- a/src/init.jl +++ b/src/init.jl @@ -29,49 +29,41 @@ function __init__() @require HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" begin fn = joinpath(@__DIR__, "backends", "hdf5.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require InspectDR = "d0351b0e-4b05-5898-87b3-e2a8edfddd1d" begin fn = joinpath(@__DIR__, "backends", "inspectdr.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require PGFPlots = "3b7a836e-365b-5785-a47d-02c71176b4aa" begin fn = joinpath(@__DIR__, "backends", "deprecated", "pgfplots.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require ORCA = "47be7bcc-f1a6-5447-8b36-7eeeff7534fd" begin fn = joinpath(@__DIR__, "backends", "orca.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" begin fn = joinpath(@__DIR__, "backends", "pgfplotsx.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" begin fn = joinpath(@__DIR__, "backends", "plotlyjs.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" begin fn = joinpath(@__DIR__, "backends", "pyplot.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" begin fn = joinpath(@__DIR__, "backends", "unicodeplots.jl") include(fn) - @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn) end @require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" begin From 02e6d729c1876b3296123ff2069dc415f544c7de Mon Sep 17 00:00:00 2001 From: Cornelius-G Date: Tue, 26 May 2020 18:37:58 +0200 Subject: [PATCH 02/11] add attribute fillalpha to contourf seriestype for pyplot backend (#2732) --- src/backends/pyplot.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 75384b37..e7ff3019 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -661,6 +661,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) handle = ax."contourf"(x, y, z, levelargs...; label = series[:label], zorder = series[:series_plotindex] + 0.5, + alpha = series[:fillalpha], extrakw... ) push!(handles, handle) @@ -1098,7 +1099,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) end pyaxis."label"."set_fontsize"(py_thickness_scale(plt, axis[:guidefontsize])) pyaxis."label"."set_family"(axis[:guidefontfamily]) - + if (RecipesPipeline.is3d(sp)) pyaxis."set_rotate_label"(false) end From 42e2266530bbac646b7dc0eb997d1e712d21400b Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 26 May 2020 20:40:44 +0200 Subject: [PATCH 03/11] Fix showaxis (#2733) * also replace axis syms * include test_axes [skip ci] * Create test_axes.jl * process showaxis --- src/args.jl | 3 ++- src/axes.jl | 1 - test/runtests.jl | 1 + test/test_axes.jl | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/test_axes.jl diff --git a/src/args.jl b/src/args.jl index da028e21..536f9691 100644 --- a/src/args.jl +++ b/src/args.jl @@ -946,7 +946,8 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) # handle axis args common to all axis args = RecipesPipeline.pop_kw!(plotattributes, :axis, ()) - for arg in wraptuple(args) + showarg = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :showaxis, ())) + for arg in wraptuple((args..., showarg...)) for letter in (:x, :y, :z) process_axis_arg!(plotattributes, arg, letter) end diff --git a/src/axes.jl b/src/axes.jl index 0979186a..c4883a1f 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -35,7 +35,6 @@ end function process_axis_arg!(plotattributes::AKW, arg, letter = "") T = typeof(arg) arg = get(_scaleAliases, arg, arg) - if typeof(arg) <: Font plotattributes[Symbol(letter,:tickfont)] = arg plotattributes[Symbol(letter,:guidefont)] = arg diff --git a/test/runtests.jl b/test/runtests.jl index a6a88b31..696e147e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,7 @@ using LibGit2 using GeometryTypes using Dates +include("test_axes.jl") include("test_hdf5plots.jl") include("test_pgfplotsx.jl") diff --git a/test/test_axes.jl b/test/test_axes.jl new file mode 100644 index 00000000..52904b4a --- /dev/null +++ b/test/test_axes.jl @@ -0,0 +1,6 @@ +using Plots, Test + +@testset "Showaxis" begin + @test plot(1:5, showaxis = :y)[1][:yaxis][:showaxis] == true + @test plot(1:5, showaxis = :y)[1][:xaxis][:showaxis] == false +end From a270e342b70f3f3dc1637aa43863736ba77c3767 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 26 May 2020 20:41:45 +0200 Subject: [PATCH 04/11] bump version [skip ci] --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index b947b346..cff1960c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "1.3.3" +version = "1.3.4" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 8c6295658b3567c073ddfb92ecee9a10173fc830 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 27 May 2020 15:23:02 +0200 Subject: [PATCH 05/11] fix showaxis fix (#2737) * also replace axis syms * process showaxis * fix axis keyword --- src/args.jl | 2 +- test/test_axes.jl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/args.jl b/src/args.jl index 536f9691..f83d98ed 100644 --- a/src/args.jl +++ b/src/args.jl @@ -945,7 +945,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) replaceAliases!(plotattributes, _keyAliases) # handle axis args common to all axis - args = RecipesPipeline.pop_kw!(plotattributes, :axis, ()) + args = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :axis, ())) showarg = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :showaxis, ())) for arg in wraptuple((args..., showarg...)) for letter in (:x, :y, :z) diff --git a/test/test_axes.jl b/test/test_axes.jl index 52904b4a..07db6102 100644 --- a/test/test_axes.jl +++ b/test/test_axes.jl @@ -1,6 +1,14 @@ using Plots, Test @testset "Showaxis" begin + for value in Plots._allShowaxisArgs + @test plot(1:5, showaxis = value)[1][:yaxis][:showaxis] isa Bool + end @test plot(1:5, showaxis = :y)[1][:yaxis][:showaxis] == true @test plot(1:5, showaxis = :y)[1][:xaxis][:showaxis] == false end + +@testset "Magic axis" begin + @test plot(1, axis=nothing)[1][:xaxis][:ticks] == [] + @test plot(1, axis=nothing)[1][:yaxis][:ticks] == [] +end # testset From 4389160a6afbfe96db2e8cadd955f9dfde67ebc9 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 27 May 2020 15:23:48 +0200 Subject: [PATCH 06/11] bumb version [skip ci] --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index cff1960c..ea638fb6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "1.3.4" +version = "1.3.5" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 995c7d349e4ef0ad605f61f6d7c93e49b69a512e Mon Sep 17 00:00:00 2001 From: Miles Lucas Date: Wed, 27 May 2020 11:55:49 -1000 Subject: [PATCH 07/11] fix type restriction in process_clims --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index eaeeb3b1..895d1ce3 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -420,7 +420,7 @@ ylims(sp_idx::Int = 1) = ylims(current(), sp_idx) zlims(sp_idx::Int = 1) = zlims(current(), sp_idx) # These functions return an operator for use in `get_clims(::Seres, op)` -process_clims(lims::NTuple{2,<:Number}) = (zlims -> ifelse.(isfinite.(lims), lims, zlims)) ∘ ignorenan_extrema +process_clims(lims::Tuple{<:Number,<:Number}) = (zlims -> ifelse.(isfinite.(lims), lims, zlims)) ∘ ignorenan_extrema process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema # don't specialize on ::Function otherwise python functions won't work process_clims(f) = f From ee1f9484485f673cb9c2971239859eb4477743f7 Mon Sep 17 00:00:00 2001 From: Miles Lucas Date: Wed, 27 May 2020 12:00:53 -1000 Subject: [PATCH 08/11] add process_clims tests --- test/runtests.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 696e147e..99c13cad 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -179,4 +179,9 @@ end @test isequal(collect(zip(Plots.unzip(z)...)), z) @test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z) end + op1 = process_clims((1.0, 2.0)) + op2 = process_clims((1, 2.0)) + data = randn(100, 100) + @test op1(data) == op2(data) + @test process_clims(nothing) == process_clims(missing) == process_clims(:auto) end From de81220c0118377bbbd37d3c91781d1397a0acc9 Mon Sep 17 00:00:00 2001 From: Miles Lucas Date: Wed, 27 May 2020 12:16:20 -1000 Subject: [PATCH 09/11] fix namespace --- test/runtests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 99c13cad..68f50988 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -179,9 +179,9 @@ end @test isequal(collect(zip(Plots.unzip(z)...)), z) @test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z) end - op1 = process_clims((1.0, 2.0)) - op2 = process_clims((1, 2.0)) + op1 = Plots.process_clims((1.0, 2.0)) + op2 = Plots.process_clims((1, 2.0)) data = randn(100, 100) @test op1(data) == op2(data) - @test process_clims(nothing) == process_clims(missing) == process_clims(:auto) + @test Plots.process_clims(nothing) == Plots.process_clims(missing) == Plots.process_clims(:auto) end From 580ac8a9d1c638e06c6c0689d3155acdd77fa628 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 29 May 2020 09:42:44 +0200 Subject: [PATCH 10/11] fix infinite objects with log scale --- src/recipes.jl | 6 +++--- src/utils.jl | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index e7bdb7ac..d2a0542f 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -112,7 +112,7 @@ end @recipe function f(::Type{Val{:hline}}, x, y, z) n = length(y) - newx = repeat(Float64[-1, 1, NaN], n) + newx = repeat(Float64[1, 2, NaN], n) newy = vec(Float64[yi for i = 1:3, yi in y]) x := newx y := newy @@ -124,7 +124,7 @@ end @recipe function f(::Type{Val{:vline}}, x, y, z) n = length(y) newx = vec(Float64[yi for i = 1:3, yi in y]) - newy = repeat(Float64[-1, 1, NaN], n) + newy = repeat(Float64[1, 2, NaN], n) x := newx y := newy seriestype := :straightline @@ -1028,7 +1028,7 @@ end function error_style!(plotattributes::AKW) plotattributes[:seriestype] = :path - plotattributes[:markercolor] = plotattributes[:markerstrokecolor] + plotattributes[:markercolor] = plotattributes[:markerstrokecolor] plotattributes[:linewidth] = plotattributes[:markerstrokewidth] plotattributes[:label] = "" end diff --git a/src/utils.jl b/src/utils.jl index 895d1ce3..c288b8a3 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1079,10 +1079,21 @@ end function straightline_data(series, expansion_factor = 1) sp = series[:subplot] xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp)) - x, y = series[:x], series[:y] + + # handle axes scales + xscale = sp[:xaxis][:scale] + xf = RecipesPipeline.scale_func(xscale) + xinvf = RecipesPipeline.inverse_scale_func(xscale) + yscale = sp[:yaxis][:scale] + yf = RecipesPipeline.scale_func(yscale) + yinvf = RecipesPipeline.inverse_scale_func(yscale) + + xl, yl = xf.(xl), yf.(yl) + x, y = xf.(series[:x]), yf.(series[:y]) n = length(x) - if n == 2 - return straightline_data(xl, yl, x, y, expansion_factor) + + xdata, ydata = if n == 2 + straightline_data(xl, yl, x, y, expansion_factor) else k, r = divrem(n, 3) if r == 0 @@ -1091,11 +1102,13 @@ function straightline_data(series, expansion_factor = 1) inds = (3 * i - 2):(3 * i - 1) xdata[inds], ydata[inds] = straightline_data(xl, yl, x[inds], y[inds], expansion_factor) end - return xdata, ydata + xdata, ydata else error("Misformed data. `straightline_data` either accepts vectors of length 2 or 3k. The provided series has length $n") end end + + return xinvf.(xdata), yinvf.(ydata) end function straightline_data(xl, yl, x, y, expansion_factor = 1) @@ -1127,20 +1140,28 @@ end function shape_data(series, expansion_factor = 1) sp = series[:subplot] xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp)) + + # handle axes scales + xscale = sp[:xaxis][:scale] + xf = RecipesPipeline.scale_func(xscale) + xinvf = RecipesPipeline.inverse_scale_func(xscale) + yscale = sp[:yaxis][:scale] + yf = RecipesPipeline.scale_func(yscale) + yinvf = RecipesPipeline.inverse_scale_func(yscale) + x, y = copy(series[:x]), copy(series[:y]) - factor = 100 for i in eachindex(x) if x[i] == -Inf - x[i] = xl[1] - expansion_factor * (xl[2] - xl[1]) + x[i] = xinvf(xf(xl[1]) - expansion_factor * (xf(xl[2]) - xf(xl[1]))) elseif x[i] == Inf - x[i] = xl[2] + expansion_factor * (xl[2] - xl[1]) + x[i] = xinvf(xf(xl[2]) + expansion_factor * (xf(xl[2]) - xf(xl[1]))) end end for i in eachindex(y) if y[i] == -Inf - y[i] = yl[1] - expansion_factor * (yl[2] - yl[1]) + y[i] = yinvf(yf(yl[1]) - expansion_factor * (yf(yl[2]) - yf(yl[1]))) elseif y[i] == Inf - y[i] = yl[2] + expansion_factor * (yl[2] - yl[1]) + y[i] = yinvf(yf(yl[2]) + expansion_factor * (yf(yl[2]) - yf(yl[1]))) end end return x, y From 0485b1313a81cf90623fc740aea6ab41ce879663 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 29 May 2020 15:16:15 +0200 Subject: [PATCH 11/11] bump version [skip ci] --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ea638fb6..756f6b99 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "1.3.5" +version = "1.3.6" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"