diff --git a/src/arg_desc.jl b/src/arg_desc.jl index e03636a26..ece7aa17b 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -118,7 +118,7 @@ const _arg_desc = KW( :colorbar_tickfontsize => "Integer. Font pointsize of colorbar tick entries.", :colorbar_tickfontcolor => "Color Type. Font color of colorbar tick entries", :colorbar_scale => "Symbol. Scale of the colorbar axis: `:none`, `:ln`, `:log2`, `:log10`", - :colorbar_formatter => "Function, :scientific, :plain or :auto. A method which converts a number to a string for tick labeling.", + :colorbar_formatter => "Function, :scientific, :plain, :none, :auto. A method which converts a number to a string for tick labeling.", :legend_font => "Font. Font of legend items.", :legend_titlefont => "Font. Font of the legend title.", :annotations => "(x,y,text) tuple(s). Can be a single tuple or a list of them. Text can be String, PlotText (created with `text(args...)`), or a tuple of arguments to `text` (e.g., `(\"Label\", 8, :red, :top)`). Add one-off text annotations at the x,y coordinates.", diff --git a/src/axes.jl b/src/axes.jl index 8a0bb20d2..79c1949d0 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -186,6 +186,8 @@ function optimal_ticks_and_labels(ticks, alims, scale, formatter) x -> string("\$", replace(convert_sci_unicode(x), '×' => "\\times"), "\$"), Showoff.showoff(unscaled_ticks, :auto), ) + elseif formatter === :none + String[] else # there was an override for the formatter... use that on the unscaled ticks map(formatter, unscaled_ticks) @@ -196,12 +198,9 @@ function optimal_ticks_and_labels(ticks, alims, scale, formatter) # end end else - # no finite ticks to show... - String[] + String[] # no finite ticks to show... end - # @show unscaled_ticks labels - # labels = Showoff.showoff(unscaled_ticks, scale === :log10 ? :scientific : :auto) unscaled_ticks, labels end diff --git a/src/utils.jl b/src/utils.jl index ca77c1116..6c5b82204 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -82,7 +82,7 @@ function series_segments(series::Series, seriestype::Symbol = :path; check = fal (scale = get(series, scales[n], :identity)) ∈ _logScales || continue for (i, v) in enumerate(s) if v <= 0 - @warn "Invalid negative or zero value $v found at series index $i for $(scale) based $(scales[n])" + @warn "Invalid negative or zero value $v found at series index $i for $scale based $(scales[n])" @debug "" exception = (DomainError(v), stacktrace()) break end @@ -153,8 +153,7 @@ anynan(istart::Int, iend::Int, args::Tuple) = any(anynan(args), istart:iend) allnan(istart::Int, iend::Int, args::Tuple) = all(anynan(args), istart:iend) function Base.iterate(itr::NaNSegmentsIterator, nextidx::Int = itr.n1) - i = findfirst(!anynan(itr.args), nextidx:(itr.n2)) - i === nothing && return + (i = findfirst(!anynan(itr.args), nextidx:(itr.n2))) === nothing && return nextval = nextidx + i - 1 j = findfirst(anynan(itr.args), nextval:(itr.n2)) @@ -162,7 +161,7 @@ function Base.iterate(itr::NaNSegmentsIterator, nextidx::Int = itr.n1) nextval:(nextnan - 1), nextnan end -Base.IteratorSize(::NaNSegmentsIterator) = Base.SizeUnknown() +Base.IteratorSize(::NaNSegmentsIterator) = Base.SizeUnknown() # COV_EXCL_LINE # Find minimal type that can contain NaN and x # To allow use of NaN separated segments with categorical x axis @@ -197,7 +196,7 @@ makevec(v::T) where {T} = T[v] maketuple(x::Real) = (x, x) maketuple(x::Tuple) = x -RecipesPipeline.unzip(v) = unzip(v) +RecipesPipeline.unzip(v) = unzip(v) # COV_EXCL_LINE replaceAlias!(plotattributes::AKW, k::Symbol, aliases::Dict{Symbol,Symbol}) = if haskey(aliases, k) @@ -215,7 +214,7 @@ function _heatmap_edges(v::AVec, isedges::Bool = false, ispolar::Bool = false) vmin, vmax = ignorenan_extrema(v) extra_min = ispolar ? min(v[1], (v[2] - v[1]) / 2) : (v[2] - v[1]) / 2 extra_max = (v[end] - v[end - 1]) / 2 - vcat(vmin - extra_min, 0.5 * (v[1:(end - 1)] + v[2:end]), vmax + extra_max) + vcat(vmin - extra_min, 0.5(v[1:(end - 1)] + v[2:end]), vmax + extra_max) end "create an (n+1) list of the outsides of heatmap rectangles" @@ -268,7 +267,7 @@ fakedata(sz::Int...) = fakedata(Random.seed!(PLOTS_SEED), sz...) function fakedata(rng::AbstractRNG, sz...) y = zeros(sz...) for r in 2:size(y, 1) - y[r, :] = 0.95 * vec(y[r - 1, :]) + randn(rng, size(y, 2)) + y[r, :] = 0.95vec(y[r - 1, :]) + randn(rng, size(y, 2)) end y end @@ -706,10 +705,8 @@ end function copy_series!(series, letter) plt = series[:plot_object] for s in plt.series_list, l in (:x, :y, :z) - if s !== series || l !== letter - if s[l] === series[letter] - series[letter] = copy(series[letter]) - end + if (s !== series || l !== letter) && s[l] === series[letter] + series[letter] = copy(series[letter]) end end end diff --git a/test/test_axes.jl b/test/test_axes.jl index 90d772abe..1b819bdc6 100644 --- a/test/test_axes.jl +++ b/test/test_axes.jl @@ -204,3 +204,9 @@ end @test Plots.expand_extrema!(ax, nothing) == ax[:extrema] @test Plots.expand_extrema!(ax, true) == ax[:extrema] end + +@testset "no labels" begin + # github.com/JuliaPlots/Plots.jl/issues/4475 + pl = plot(100:100:300, hcat([1, 2, 4], [-1, -2, -4]); yformatter = :none) + @test pl[1][:yaxis][:formatter] === :none +end diff --git a/test/test_utils.jl b/test/test_utils.jl index c988971a6..d3f949e5b 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -159,6 +159,13 @@ end @test segments([nan10; 1:15], [1:15; nan10]) == [11:15] end +@testset "Invalid scale values" begin + @test_logs match_mode = :any (:warn, r"Invalid negative or zero value.*") png( + plot([0, 1], yscale = :log10), + tempname(), + ) +end + @testset "Triangulation" begin x = [0, 1, 2, 0] y = [0, 0, 1, 2]