diff --git a/Project.toml b/Project.toml index 12caa53..02e0f64 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UnitfulRecipes" uuid = "42071c24-d89e-48dd-8a24-8a12d9b8861f" authors = ["Benoit Pasquier", "Jan Weidner"] -version = "1.0.0" +version = "1.0.1" [deps] RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" diff --git a/docs/lit/examples/2_Plots.jl b/docs/lit/examples/2_Plots.jl index 0bfd1c8..c9cec81 100644 --- a/docs/lit/examples/2_Plots.jl +++ b/docs/lit/examples/2_Plots.jl @@ -39,7 +39,7 @@ y = rand(20, 3)*u"W" x = (1:size(y,1))*u"Hz" plot(x, y, xlabel="XLABEL", xlims=(-5, 30), xflip=true, xticks=0:2:20, background_color=RGB(0.2, 0.2, 0.2), leg=false) hline!(mean(y, dims=1) + rand(1, 3)*u"W", line=(4, :dash, 0.6, [:lightgreen :green :darkgreen])) -vline!([5, 10]*u"W") # this is a current Plots v1.0.3 bug. Should be Hz +vline!([5, 10]*u"Hz") title!("TITLE") yaxis!("YLABEL", :log10) diff --git a/src/UnitfulRecipes.jl b/src/UnitfulRecipes.jl index ea84c41..286ef3d 100644 --- a/src/UnitfulRecipes.jl +++ b/src/UnitfulRecipes.jl @@ -114,11 +114,11 @@ Label string containing unit information =======================================# abstract type AbstractProtectedString <: AbstractString end -struct ProtectedString <: AbstractProtectedString - content::String +struct ProtectedString{S} <: AbstractProtectedString + content::S end -struct UnitfulString{U} <: AbstractProtectedString - content::String +struct UnitfulString{S,U} <: AbstractProtectedString + content::S unit::U end # Minimum required AbstractString interface to work with Plots @@ -161,9 +161,9 @@ append_unit_if_needed!(attr, key, label::UnitfulString, u) = nothing function append_unit_if_needed!(attr, key, label::Nothing, u) attr[key] = UnitfulString(string(u), u) end -function append_unit_if_needed!(attr, key, label::String, u) +function append_unit_if_needed!(attr, key, label::S, u) where {S <: AbstractString} if label ≠ "" - attr[key] = UnitfulString(string(label, " (", u, ")"), u) + attr[key] = UnitfulString(S(string(label, " (", u, ")")), u) end end