From 5194e49b4cbb371716ba41c9efa814a0f43d0296 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 22 Mar 2020 18:31:08 +0100 Subject: [PATCH 01/19] test on 1.4 and update version --- .gitignore | 1 + .travis.yml | 2 +- Project.toml | 2 +- appveyor.yml | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0c89a967..6e5cdbe6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ deps/build.log deps/deps.jl Manifest.toml dev/ +test/tmpplotsave.hdf5 diff --git a/.travis.yml b/.travis.yml index b8ae53eb..113a0972 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ os: # - osx julia: - 1 - - 1.3 + - 1.4 - nightly matrix: diff --git a/Project.toml b/Project.toml index f03c1ed2..26d82018 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "0.29.8" +version = "0.29.9" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/appveyor.yml b/appveyor.yml index 890f4960..61883cf7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ environment: matrix: # - julia_version: 0.7 - julia_version: 1 - - julia_version: 1.3 + - julia_version: 1.4 - julia_version: nightly platform: @@ -36,7 +36,7 @@ build_script: - C:\julia\bin\julia --project=C:\projects\plots-jl -e "using Pkg; Pkg.pin(PackageSpec(name="""FixedPointNumbers""", version="""0.7"""))" - echo "%JL_BUILD_SCRIPT%" - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" - + test_script: - echo "%JL_TEST_SCRIPT%" - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" From b0548ffc14342136f1828f3db0239d60bc5d0d18 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Mon, 23 Mar 2020 23:12:13 +0100 Subject: [PATCH 02/19] make type recipe aware of current axis --- src/series.jl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/series.jl b/src/series.jl index 3a79d478..32982d13 100644 --- a/src/series.jl +++ b/src/series.jl @@ -175,9 +175,9 @@ end @recipe f(::Type{V}, x, y, z) where {V<:Val} = error("The backend must not support the series type $V, and there isn't a series recipe defined.") function _apply_type_recipe(plotattributes, v, letter) - _handle_axis_args!(plotattributes) + _preprocess_axis_args!(plotattributes, letter) rdvec = RecipesBase.apply_recipe(plotattributes, typeof(v), v) - _handle_axis_args!(plotattributes, letter) + _postprocess_axis_args!(plotattributes, letter) return rdvec[1].args[1] end @@ -185,7 +185,7 @@ end # This sort of recipe should return a pair of functions... one to convert to number, # and one to format tick values. function _apply_type_recipe(plotattributes, v::AbstractArray, letter) - _handle_axis_args!(plotattributes) + _preprocess_axis_args!(plotattributes, letter) # First we try to apply an array type recipe. w = RecipesBase.apply_recipe(plotattributes, typeof(v), v)[1].args[1] # If the type did not change try it element-wise @@ -193,7 +193,7 @@ function _apply_type_recipe(plotattributes, v::AbstractArray, letter) isempty(skipmissing(v)) && return Float64[] x = first(skipmissing(v)) args = RecipesBase.apply_recipe(plotattributes, typeof(x), x)[1].args - _handle_axis_args!(plotattributes, letter) + _postprocess_axis_args!(plotattributes, letter) if length(args) == 2 && all(arg -> arg isa Function, args) numfunc, formatter = args return Formatted(map(numfunc, v), formatter) @@ -201,7 +201,7 @@ function _apply_type_recipe(plotattributes, v::AbstractArray, letter) return v end end - _handle_axis_args!(plotattributes, letter) + _postprocess_axis_args!(plotattributes, letter) return w end @@ -225,7 +225,8 @@ end _apply_type_recipe(plotattributes, v::AbstractArray{T}, letter) where {T<:Union{Integer,AbstractFloat}} = v # axis args in type recipes should only be applied to the current axis -function _handle_axis_args!(plotattributes, letter) +function _postprocess_axis_args!(plotattributes, letter) + pop!(plotattributes, :letter) if letter in (:x, :y, :z) replaceAliases!(plotattributes, _keyAliases) for (k, v) in plotattributes @@ -239,13 +240,14 @@ function _handle_axis_args!(plotattributes, letter) end # axis args before type recipes should still be mapped to all axes -function _handle_axis_args!(plotattributes) +function _preprocess_axis_args!(plotattributes, letter) replaceAliases!(plotattributes, _keyAliases) + plotattributes[:letter] = letter for (k, v) in plotattributes if haskey(_axis_defaults, k) pop!(plotattributes, k) - for letter in (:x, :y, :z) - lk = Symbol(letter, k) + for l in (:x, :y, :z) + lk = Symbol(l, k) haskey(plotattributes, lk) || (plotattributes[lk] = v) end end From 8efd0f00c4d761031ae168ab63016ae5d22863fa Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 25 Mar 2020 10:45:46 +0100 Subject: [PATCH 03/19] fix pin --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 113a0972..0ca9ae82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,4 @@ notifications: script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - if [[ `uname` = "Linux" ]]; then TESTCMD="xvfb-run julia"; else TESTCMD="julia"; fi - - $TESTCMD -e 'using Pkg; Pkg.pin(PackageSpec(name="FixedPointNumbers", version="0.7")); Pkg.build(); Pkg.test(coverage=true)' + - $TESTCMD -e 'using Pkg; Pkg.resolve(); Pkg.pin(PackageSpec(name="FixedPointNumbers", version="0.7")); Pkg.build(); Pkg.test(coverage=true)' From 17db6c01b4fdb763ca58d902ace9ffe97b51d03c Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 25 Mar 2020 12:51:49 +0100 Subject: [PATCH 04/19] keep no-letter version of `_preprocess_axis_args!` --- src/series.jl | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/series.jl b/src/series.jl index 32982d13..ac5f9213 100644 --- a/src/series.jl +++ b/src/series.jl @@ -224,6 +224,24 @@ end # don't do anything for ints or floats _apply_type_recipe(plotattributes, v::AbstractArray{T}, letter) where {T<:Union{Integer,AbstractFloat}} = v +# axis args before type recipes should still be mapped to all axes +function _preprocess_axis_args!(plotattributes) + replaceAliases!(plotattributes, _keyAliases) + for (k, v) in plotattributes + if haskey(_axis_defaults, k) + pop!(plotattributes, k) + for l in (:x, :y, :z) + lk = Symbol(l, k) + haskey(plotattributes, lk) || (plotattributes[lk] = v) + end + end + end +end +function _preprocess_axis_args!(plotattributes, letter) + plotattributes[:letter] = letter + _preprocess_axis_args!(plotattributes) +end + # axis args in type recipes should only be applied to the current axis function _postprocess_axis_args!(plotattributes, letter) pop!(plotattributes, :letter) @@ -239,21 +257,6 @@ function _postprocess_axis_args!(plotattributes, letter) end end -# axis args before type recipes should still be mapped to all axes -function _preprocess_axis_args!(plotattributes, letter) - replaceAliases!(plotattributes, _keyAliases) - plotattributes[:letter] = letter - for (k, v) in plotattributes - if haskey(_axis_defaults, k) - pop!(plotattributes, k) - for l in (:x, :y, :z) - lk = Symbol(l, k) - haskey(plotattributes, lk) || (plotattributes[lk] = v) - end - end - end -end - # handle "type recipes" by converting inputs, and then either re-calling or slicing @recipe function f(x, y, z) did_replace = false From dd3216489b3e7e30df14cfb0409fbf7485a2d2f4 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 25 Mar 2020 14:48:57 +0100 Subject: [PATCH 05/19] resolve conditionally --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0ca9ae82..e380db24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,4 @@ notifications: script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - if [[ `uname` = "Linux" ]]; then TESTCMD="xvfb-run julia"; else TESTCMD="julia"; fi - - $TESTCMD -e 'using Pkg; Pkg.resolve(); Pkg.pin(PackageSpec(name="FixedPointNumbers", version="0.7")); Pkg.build(); Pkg.test(coverage=true)' + - $TESTCMD -e 'using Pkg; VERSION == v"1.4" ? Pkg.resolve() : nothing; Pkg.pin(PackageSpec(name="FixedPointNumbers", version="0.7")); Pkg.build(); Pkg.test(coverage=true)' From 53183529297e9aa835bd4f4dce9cdcfb1327af70 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 25 Mar 2020 14:50:42 +0100 Subject: [PATCH 06/19] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 61883cf7..c67bb234 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,7 @@ install: - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) build_script: - - C:\julia\bin\julia --project=C:\projects\plots-jl -e "using Pkg; Pkg.pin(PackageSpec(name="""FixedPointNumbers""", version="""0.7"""))" + - C:\julia\bin\julia --project=C:\projects\plots-jl -e "using Pkg; VERSION == v"""1.4""" ? Pkg.resolve() : nothing; Pkg.pin(PackageSpec(name="""FixedPointNumbers""", version="""0.7"""))" - echo "%JL_BUILD_SCRIPT%" - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" From c684213106e5ec43cd6626f63c73185d09185154 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 25 Mar 2020 15:04:39 +0100 Subject: [PATCH 07/19] fix `AbstractArray{<:Missing}` --- src/series.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/series.jl b/src/series.jl index ac5f9213..afebde8e 100644 --- a/src/series.jl +++ b/src/series.jl @@ -20,6 +20,7 @@ function prepareSeriesData(a::AbstractArray{<:MaybeNumber}) f = isimmutable(a) ? replace : replace! a = f(x -> ismissing(x) || isinf(x) ? NaN : x, map(float, a)) end +prepareSeriesData(a::AbstractArray{<:Missing}) = fill(NaN, axes(a)) prepareSeriesData(a::AbstractArray{<:MaybeString}) = replace(x -> ismissing(x) ? "" : x, a) prepareSeriesData(s::Surface{<:AMat{<:MaybeNumber}}) = Surface(prepareSeriesData(s.surf)) prepareSeriesData(s::Surface) = s # non-numeric Surface, such as an image @@ -222,7 +223,7 @@ end # end # don't do anything for ints or floats -_apply_type_recipe(plotattributes, v::AbstractArray{T}, letter) where {T<:Union{Integer,AbstractFloat}} = v +_apply_type_recipe(plotattributes, v::AbstractArray{<:DataPoint}, letter) = v # axis args before type recipes should still be mapped to all axes function _preprocess_axis_args!(plotattributes) From d9a48ac7de4e67e13dfb74a1dd26c7b2eef200fa Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 25 Mar 2020 16:36:04 +0100 Subject: [PATCH 08/19] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e380db24..aa1f8bfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,4 @@ notifications: script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - if [[ `uname` = "Linux" ]]; then TESTCMD="xvfb-run julia"; else TESTCMD="julia"; fi - - $TESTCMD -e 'using Pkg; VERSION == v"1.4" ? Pkg.resolve() : nothing; Pkg.pin(PackageSpec(name="FixedPointNumbers", version="0.7")); Pkg.build(); Pkg.test(coverage=true)' + - $TESTCMD -e 'using Pkg; if VERSION == v"1.4"; Pkg.resolve(); end; Pkg.pin(PackageSpec(name="FixedPointNumbers", version="0.7")); Pkg.build(); Pkg.test(coverage=true)' From c37829eafb8d49a92e95d4a32a9c29c9386e07f8 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 25 Mar 2020 16:55:53 +0100 Subject: [PATCH 09/19] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c67bb234..7742efb2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,7 @@ install: - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) build_script: - - C:\julia\bin\julia --project=C:\projects\plots-jl -e "using Pkg; VERSION == v"""1.4""" ? Pkg.resolve() : nothing; Pkg.pin(PackageSpec(name="""FixedPointNumbers""", version="""0.7"""))" + - C:\julia\bin\julia --project=C:\projects\plots-jl -e "using Pkg; if VERSION == v"""1.4"""; Pkg.resolve(); end; Pkg.pin(PackageSpec(name="""FixedPointNumbers""", version="""0.7"""))" - echo "%JL_BUILD_SCRIPT%" - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" From 932d0da73de46dc271947a73299479f5b182a0ec Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 26 Mar 2020 15:09:31 +0100 Subject: [PATCH 10/19] move `replaceAliases!` out of recipe processing --- src/args.jl | 4 ++-- src/pipeline.jl | 6 +++--- src/series.jl | 2 -- src/types.jl | 7 ++++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/args.jl b/src/args.jl index 82ca09d8..b388c641 100644 --- a/src/args.jl +++ b/src/args.jl @@ -916,8 +916,8 @@ function _add_markershape(plotattributes::AKW) end "Handle all preprocessing of args... break out colors/sizes/etc and replace aliases." -function preprocessArgs!(plotattributes::AKW) - replaceAliases!(plotattributes, _keyAliases) +function preprocessArgs!(plotattributes::AKW, replace_aliases = true) + replace_aliases && replaceAliases!(plotattributes, _keyAliases) # clear all axis stuff # if haskey(plotattributes, :axis) && plotattributes[:axis] in (:none, nothing, false) diff --git a/src/pipeline.jl b/src/pipeline.jl index 1e9cd991..383ac82a 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -96,7 +96,7 @@ function _process_userrecipe(plt::Plot, kw_list::Vector{KW}, recipedata::RecipeD # when the arg tuple is empty, that means there's nothing left to recursively # process... finish up and add to the kw_list kw = recipedata.plotattributes - preprocessArgs!(kw) + preprocessArgs!(kw, false) _preprocess_userrecipe(kw) warnOnUnsupported_scales(plt.backend, kw) @@ -185,7 +185,7 @@ function _process_plotrecipe(plt::Plot, kw::AKW, kw_list::Vector{KW}, still_to_p st = kw[:seriestype] = get(_typeAliases, st, st) datalist = RecipesBase.apply_recipe(kw, Val{st}, plt) for data in datalist - preprocessArgs!(data.plotattributes) + preprocessArgs!(data.plotattributes, false) if data.plotattributes[:seriestype] == st error("Plot recipe $st returned the same seriestype: $(data.plotattributes)") end @@ -413,7 +413,7 @@ function _process_seriesrecipe(plt::Plot, plotattributes::AKW) # assuming there was no error, recursively apply the series recipes for data in datalist if isa(data, RecipeData) - preprocessArgs!(data.plotattributes) + preprocessArgs!(data.plotattributes, false) if data.plotattributes[:seriestype] == st error("The seriestype didn't change in series recipe $st. This will cause a StackOverflow.") end diff --git a/src/series.jl b/src/series.jl index afebde8e..3e76d93a 100644 --- a/src/series.jl +++ b/src/series.jl @@ -227,7 +227,6 @@ _apply_type_recipe(plotattributes, v::AbstractArray{<:DataPoint}, letter) = v # axis args before type recipes should still be mapped to all axes function _preprocess_axis_args!(plotattributes) - replaceAliases!(plotattributes, _keyAliases) for (k, v) in plotattributes if haskey(_axis_defaults, k) pop!(plotattributes, k) @@ -247,7 +246,6 @@ end function _postprocess_axis_args!(plotattributes, letter) pop!(plotattributes, :letter) if letter in (:x, :y, :z) - replaceAliases!(plotattributes, _keyAliases) for (k, v) in plotattributes if haskey(_axis_defaults, k) pop!(plotattributes, k) diff --git a/src/types.jl b/src/types.jl index 4ee8e9e0..a866e59f 100644 --- a/src/types.jl +++ b/src/types.jl @@ -26,8 +26,9 @@ struct Attr <: AbstractDict{Symbol,Any} defaults::KW end -Base.getindex(attr::Attr, k) = haskey(attr.explicit,k) ? - attr.explicit[k] : attr.defaults[k] +function Base.getindex(attr::Attr, k) + return haskey(attr.explicit, k) ? attr.explicit[k] : attr.defaults[k] +end Base.haskey(attr::Attr, k) = haskey(attr.explicit,k) || haskey(attr.defaults,k) Base.get(attr::Attr, k, default) = haskey(attr, k) ? attr[k] : default function Base.get!(attr::Attr, k, default) @@ -41,7 +42,7 @@ end function Base.delete!(attr::Attr, k) haskey(attr.explicit, k) && delete!(attr.explicit, k) haskey(attr.defaults, k) && delete!(attr.defaults, k) -end +end Base.length(attr::Attr) = length(union(keys(attr.explicit), keys(attr.defaults))) function Base.iterate(attr::Attr) exp_keys = keys(attr.explicit) From f808a9fae5a541c9187b381fed9f41da877f0336 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2020 20:05:29 +0000 Subject: [PATCH 11/19] CompatHelper: bump compat for "StatsBase" to "0.33" --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index f03c1ed2..b85ce998 100644 --- a/Project.toml +++ b/Project.toml @@ -46,20 +46,20 @@ RecipesBase = "0.8" Reexport = "0.2" Requires = "0.5, 1.0" Showoff = "0.3.1" -StatsBase = "0.32" +StatsBase = "0.32, 0.33" julia = "1" [extras] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb" Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" +HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" From d1465ff40156ab8adce995195be08d8515a0fb31 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Fri, 27 Mar 2020 07:07:13 +0100 Subject: [PATCH 12/19] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index b85ce998..4dd31e85 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Plots" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" author = ["Tom Breloff (@tbreloff)"] -version = "0.29.8" +version = "0.29.9" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 0c2d80841c0f4035fd2cd18edaf56a90be7a6919 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 27 Mar 2020 13:44:39 +0100 Subject: [PATCH 13/19] warn on recipe aliases --- src/args.jl | 28 ++++++++++++++++++++++++++++ src/pipeline.jl | 33 +++++++++++++++++++++++++++++++-- src/recipes.jl | 4 ++-- src/series.jl | 3 +++ 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/args.jl b/src/args.jl index b388c641..f32bfe42 100644 --- a/src/args.jl +++ b/src/args.jl @@ -460,6 +460,24 @@ is_axis_attr_noletter(k) = haskey(_axis_defaults, k) RecipesBase.is_key_supported(k::Symbol) = is_attr_supported(k) +const _internal_args = + [:plot_object, :series_plotindex, :markershape_to_add, :letter, :idxfilter] +const _magic_axis_args = [:axis, :tickfont, :guidefont] +const _magic_subplot_args = [:titlefont, :legendfont, :legendtitlefont, ] +const _magic_series_args = [:line, :marker, :fill] + +function is_default_attribute(k::Symbol) + k in _internal_args && return true + k in _all_args && return true + is_axis_attr(k) && return true + is_axis_attr_noletter(k) && return true + k in _magic_axis_args && return true + k in _magic_subplot_args && return true + k in _magic_series_args && return true + Symbol(chop(string(k); head = 1, tail = 0)) in _magic_axis_args && return true + return false +end + # ----------------------------------------------------------------------------- makeplural(s::Symbol) = Symbol(string(s,"s")) @@ -1017,6 +1035,16 @@ function preprocessArgs!(plotattributes::AKW, replace_aliases = true) end end end + # handle axes guides + if haskey(plotattributes, :guide) + guide = pop!(plotattributes, :guide) + for letter in (:x, :y, :z) + guide_sym = Symbol(letter, :guide) + if !is_explicit(plotattributes, guide_sym) + plotattributes[guide_sym] = guide + end + end + end # handle line args for arg in wraptuple(pop_kw!(plotattributes, :line, ())) diff --git a/src/pipeline.jl b/src/pipeline.jl index 383ac82a..5b4d9bf5 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -1,4 +1,26 @@ +# Error for aliases used in recipes +function warn_on_recipe_aliases!(plotattributes, recipe_type, args...) + for k in keys(plotattributes) + if !is_default_attribute(k) + dk = get(_keyAliases, k, k) + if k !== dk + @warn "Attribute alias `$k` detected in the $recipe_type recipe defined for the signature $(signature_string(Val{recipe_type}, args...)). To ensure expected behavior it is recommended to use the default attribute `$dk`." + end + plotattributes[dk] = pop_kw!(plotattributes, k) + end + end +end +warn_on_recipe_aliases!(v::AbstractVector, recipe_type, args) = + foreach(x -> warn_on_recipe_aliases!(x, recipe_type, args), v) +warn_on_recipe_aliases!(rd::RecipeData, recipe_type, args) = + warn_on_recipe_aliases!(rd.plotattributes, recipe_type, args) +function signature_string(::Type{Val{:user}}, args...) + return string("(::", join(string.(typeof.(args)), ", ::"), ")") +end +signature_string(::Type{Val{:type}}, T) = "(::Type{$T}, ::$T)" +signature_string(::Type{Val{:plot}}, st) = "(::Type{Val{:$st}}, ::AbstractPlot)" +signature_string(::Type{Val{:series}}, st) = "(::Type{Val{:$st}}, x, y, z)" # ------------------------------------------------------------------ # preprocessing @@ -82,7 +104,11 @@ function _process_userrecipes(plt::Plot, plotattributes::AKW, args) if isempty(next_series.args) _process_userrecipe(plt, kw_list, next_series) else - rd_list = RecipesBase.apply_recipe(next_series.plotattributes, next_series.args...) + rd_list = RecipesBase.apply_recipe( + next_series.plotattributes, + next_series.args... + ) + warn_on_recipe_aliases!(rd_list, :user, next_series.args) prepend!(still_to_process,rd_list) end end @@ -184,6 +210,7 @@ function _process_plotrecipe(plt::Plot, kw::AKW, kw_list::Vector{KW}, still_to_p st = kw[:seriestype] st = kw[:seriestype] = get(_typeAliases, st, st) datalist = RecipesBase.apply_recipe(kw, Val{st}, plt) + warn_on_recipe_aliases!(datalist, :plot, st) for data in datalist preprocessArgs!(data.plotattributes, false) if data.plotattributes[:seriestype] == st @@ -408,7 +435,9 @@ function _process_seriesrecipe(plt::Plot, plotattributes::AKW) else # get a sub list of series for this seriestype - datalist = RecipesBase.apply_recipe(plotattributes, Val{st}, plotattributes[:x], plotattributes[:y], plotattributes[:z]) + x, y, z = plotattributes[:x], plotattributes[:y], plotattributes[:z] + datalist = RecipesBase.apply_recipe(plotattributes, Val{st}, x, y, z) + warn_on_recipe_aliases!(datalist, :series, st) # assuming there was no error, recursively apply the series recipes for data in datalist diff --git a/src/recipes.jl b/src/recipes.jl index dc94c1a9..79b4176d 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1261,8 +1261,8 @@ end yflip := true aspect_ratio := 1 rs, cs, zs = findnz(z.surf) - xlim := ignorenan_extrema(cs) - ylim := ignorenan_extrema(rs) + xlims := ignorenan_extrema(cs) + ylims := ignorenan_extrema(rs) if plotattributes[:markershape] == :none markershape := :circle end diff --git a/src/series.jl b/src/series.jl index 3e76d93a..5df68409 100644 --- a/src/series.jl +++ b/src/series.jl @@ -178,6 +178,7 @@ end function _apply_type_recipe(plotattributes, v, letter) _preprocess_axis_args!(plotattributes, letter) rdvec = RecipesBase.apply_recipe(plotattributes, typeof(v), v) + warn_on_recipe_aliases!(plotattributes, :type, typeof(v)) _postprocess_axis_args!(plotattributes, letter) return rdvec[1].args[1] end @@ -189,11 +190,13 @@ function _apply_type_recipe(plotattributes, v::AbstractArray, letter) _preprocess_axis_args!(plotattributes, letter) # First we try to apply an array type recipe. w = RecipesBase.apply_recipe(plotattributes, typeof(v), v)[1].args[1] + warn_on_recipe_aliases!(plotattributes, :type, typeof(v)) # If the type did not change try it element-wise if typeof(v) == typeof(w) isempty(skipmissing(v)) && return Float64[] x = first(skipmissing(v)) args = RecipesBase.apply_recipe(plotattributes, typeof(x), x)[1].args + warn_on_recipe_aliases!(plotattributes, :type, typeof(x)) _postprocess_axis_args!(plotattributes, letter) if length(args) == 2 && all(arg -> arg isa Function, args) numfunc, formatter = args From 8594926b67f1010c05cd499b34dee1a31fca8ec3 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 27 Mar 2020 16:31:06 +0100 Subject: [PATCH 14/19] move `replaceAliases!` back to `preprocessArgs!` --- src/args.jl | 4 ++-- src/pipeline.jl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/args.jl b/src/args.jl index f32bfe42..a2b70326 100644 --- a/src/args.jl +++ b/src/args.jl @@ -934,8 +934,8 @@ function _add_markershape(plotattributes::AKW) end "Handle all preprocessing of args... break out colors/sizes/etc and replace aliases." -function preprocessArgs!(plotattributes::AKW, replace_aliases = true) - replace_aliases && replaceAliases!(plotattributes, _keyAliases) +function preprocessArgs!(plotattributes::AKW) + replaceAliases!(plotattributes, _keyAliases) # clear all axis stuff # if haskey(plotattributes, :axis) && plotattributes[:axis] in (:none, nothing, false) diff --git a/src/pipeline.jl b/src/pipeline.jl index 5b4d9bf5..ef846dd1 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -122,7 +122,7 @@ function _process_userrecipe(plt::Plot, kw_list::Vector{KW}, recipedata::RecipeD # when the arg tuple is empty, that means there's nothing left to recursively # process... finish up and add to the kw_list kw = recipedata.plotattributes - preprocessArgs!(kw, false) + preprocessArgs!(kw) _preprocess_userrecipe(kw) warnOnUnsupported_scales(plt.backend, kw) @@ -212,7 +212,7 @@ function _process_plotrecipe(plt::Plot, kw::AKW, kw_list::Vector{KW}, still_to_p datalist = RecipesBase.apply_recipe(kw, Val{st}, plt) warn_on_recipe_aliases!(datalist, :plot, st) for data in datalist - preprocessArgs!(data.plotattributes, false) + preprocessArgs!(data.plotattributes) if data.plotattributes[:seriestype] == st error("Plot recipe $st returned the same seriestype: $(data.plotattributes)") end @@ -442,7 +442,7 @@ function _process_seriesrecipe(plt::Plot, plotattributes::AKW) # assuming there was no error, recursively apply the series recipes for data in datalist if isa(data, RecipeData) - preprocessArgs!(data.plotattributes, false) + preprocessArgs!(data.plotattributes) if data.plotattributes[:seriestype] == st error("The seriestype didn't change in series recipe $st. This will cause a StackOverflow.") end From e9ef5c852b8841e3a4dca4507dea4dac573ead85 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 27 Mar 2020 17:09:07 +0100 Subject: [PATCH 15/19] fix magic axis args for recipes --- src/args.jl | 11 ++++++++--- src/series.jl | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/args.jl b/src/args.jl index a2b70326..cebc5344 100644 --- a/src/args.jl +++ b/src/args.jl @@ -466,12 +466,17 @@ const _magic_axis_args = [:axis, :tickfont, :guidefont] const _magic_subplot_args = [:titlefont, :legendfont, :legendtitlefont, ] const _magic_series_args = [:line, :marker, :fill] -function is_default_attribute(k::Symbol) +function is_noletter_attribute(k) + is_axis_attr_noletter(k) && return true + k in _magic_axis_args && return true + return false +end + +function is_default_attribute(k) k in _internal_args && return true k in _all_args && return true is_axis_attr(k) && return true - is_axis_attr_noletter(k) && return true - k in _magic_axis_args && return true + is_noletter_attribute(k) && return true k in _magic_subplot_args && return true k in _magic_series_args && return true Symbol(chop(string(k); head = 1, tail = 0)) in _magic_axis_args && return true diff --git a/src/series.jl b/src/series.jl index 5df68409..43cedc8b 100644 --- a/src/series.jl +++ b/src/series.jl @@ -231,7 +231,7 @@ _apply_type_recipe(plotattributes, v::AbstractArray{<:DataPoint}, letter) = v # axis args before type recipes should still be mapped to all axes function _preprocess_axis_args!(plotattributes) for (k, v) in plotattributes - if haskey(_axis_defaults, k) + if is_noletter_attribute(k) pop!(plotattributes, k) for l in (:x, :y, :z) lk = Symbol(l, k) @@ -250,7 +250,7 @@ function _postprocess_axis_args!(plotattributes, letter) pop!(plotattributes, :letter) if letter in (:x, :y, :z) for (k, v) in plotattributes - if haskey(_axis_defaults, k) + if is_noletter_attribute(k) pop!(plotattributes, k) lk = Symbol(letter, k) haskey(plotattributes, lk) || (plotattributes[lk] = v) From aa2cee405ac9374cc680d46df207ddeeb642e5a1 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 27 Mar 2020 19:52:46 +0100 Subject: [PATCH 16/19] Revert "CompatHelper: bump compat for "StatsBase" to "0.33"" --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 4dd31e85..26d82018 100644 --- a/Project.toml +++ b/Project.toml @@ -46,20 +46,20 @@ RecipesBase = "0.8" Reexport = "0.2" Requires = "0.5, 1.0" Showoff = "0.3.1" -StatsBase = "0.32, 0.33" +StatsBase = "0.32" julia = "1" [extras] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb" Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" +HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" From c5aebf1309cd3f7aa26ae738ac1436f88d3eb353 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sat, 28 Mar 2020 21:00:06 +0100 Subject: [PATCH 17/19] add Codecov coverage --- .travis.yml | 3 +++ README.md | 1 + 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index aa1f8bfe..a4ca0ed6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,9 @@ before_install: notifications: email: true +after_success: + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' + script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - if [[ `uname` = "Linux" ]]; then TESTCMD="xvfb-run julia"; else TESTCMD="julia"; fi diff --git a/README.md b/README.md index 3c57fef1..ae3a3dd9 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ [![][pkgeval-img]][pkgeval-url] [![][gitter-img]][gitter-url] [![][docs-img]][docs-url] +[![Codecov](https://codecov.io/gh/JuliaPlots/Plots.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaPlots/Plots.jl) #### Created by Tom Breloff (@tbreloff) From df9217e3b940eb3a93939ac758e868e549bc2286 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sat, 28 Mar 2020 21:52:03 +0100 Subject: [PATCH 18/19] move `/src/backends/template.jl` to `/templates/backends.jl` for coverage --- src/backends/template.jl => templates/backends.jl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/backends/template.jl => templates/backends.jl (100%) diff --git a/src/backends/template.jl b/templates/backends.jl similarity index 100% rename from src/backends/template.jl rename to templates/backends.jl From d8c4c535677cf8ddb4e1cb60a7b91352e8b794cf Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sat, 28 Mar 2020 22:54:49 +0100 Subject: [PATCH 19/19] ignore some files in coverage --- codecov.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..79baa3c2 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +ignore: + - "src/backends/inspectdr.jl" + - "src/backends/orca.jl" + - "src/backends/pgfplots.jl" + - "src/backends/plotly.jl" + - "src/backends/plotlyjs.jl" + - "src/backends/pyplot.jl" + - "src/backends/web.jl" + - "src/fileio.jl" + - "src/ijulia.jl"