From 42b3c5625f0de2c1012d0478ca007e83a51284a9 Mon Sep 17 00:00:00 2001 From: yha Date: Thu, 25 Feb 2021 02:33:11 +0200 Subject: [PATCH 1/6] Fix for "segmented" attributes with NaNs --- src/backends.jl | 1 + src/backends/gr.jl | 25 ++++++++++-------- src/backends/pgfplotsx.jl | 5 ++-- src/backends/plotly.jl | 17 +++++++----- src/backends/pyplot.jl | 14 ++++++---- src/examples.jl | 17 ++++++++++-- src/utils.jl | 54 +++++++++++++++++++-------------------- test/runtests.jl | 10 ++------ 8 files changed, 82 insertions(+), 61 deletions(-) diff --git a/src/backends.jl b/src/backends.jl index bd280f0f..6164441d 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -842,6 +842,7 @@ const _pgfplotsx_marker = [ :rtriangle, :cross, :xcross, + :x, :star5, :pentagon, :hline, diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 56693c00..1cc51624 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1561,7 +1561,7 @@ function gr_add_series(sp, series) gr_draw_markers(series, x, y, clims) end elseif st === :shape - gr_draw_shapes(series, x, y, clims) + gr_draw_shapes(series, clims) elseif st in (:path3d, :scatter3d) gr_draw_segments_3d(series, x, y, z, clims) if st === :scatter3d || series[:markershape] !== :none @@ -1613,12 +1613,13 @@ end function gr_draw_segments(series, x, y, fillrange, clims) st = series[:seriestype] if x !== nothing && length(x) > 1 - segments = iter_segments(series, st) + segments = series_segments(series, st) # do area fill if fillrange !== nothing GR.setfillintstyle(GR.INTSTYLE_SOLID) fr_from, fr_to = (is_2tuple(fillrange) ? fillrange : (y, fillrange)) - for (i, rng) in enumerate(segments) + for segment in segments + i, rng = segment.attr_index, segment.range fc = get_fillcolor(series, clims, i) gr_set_fillcolor(fc) fx = _cycle(x, vcat(rng, reverse(rng))) @@ -1630,7 +1631,8 @@ function gr_draw_segments(series, x, y, fillrange, clims) # draw the line(s) if st in (:path, :straightline) - for (i, rng) in enumerate(segments) + for segment in segments + i, rng = segment.attr_index, segment.range lc = get_linecolor(series, clims, i) gr_set_line( get_linewidth(series, i), get_linestyle(series, i), lc, series @@ -1648,8 +1650,9 @@ end function gr_draw_segments_3d(series, x, y, z, clims) if series[:seriestype] === :path3d && length(x) > 1 lz = series[:line_z] - segments = iter_segments(series, :path3d) - for (i, rng) in enumerate(segments) + segments = series_segments(series, :path3d) + for segment in segments + i, rng = segment.attr_index, segment.range lc = get_linecolor(series, clims, i) gr_set_line( get_linewidth(series, i), get_linestyle(series, i), lc, series @@ -1674,8 +1677,9 @@ function gr_draw_markers( shapes = series[:markershape] if shapes != :none - for (i, rng) in enumerate(iter_segments(series, :scatter)) - rng = intersect(eachindex(x), rng) + for segment in series_segments(series, :scatter) + i = segment.attr_index + rng = intersect(eachindex(x), segment.range) if !isempty(rng) ms = get_thickness_scaling(series) * _cycle(msize, i) msw = get_thickness_scaling(series) * _cycle(strokewidth, i) @@ -1688,9 +1692,10 @@ function gr_draw_markers( end end -function gr_draw_shapes(series, x, y, clims) +function gr_draw_shapes(series, clims) x, y = shape_data(series) - for (i,rng) in enumerate(iter_segments(x, y)) + for segment in series_segments(series, :shape) + i, rng = segment.attr_index, segment.range if length(rng) > 1 # connect to the beginning rng = vcat(rng, rng[1]) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index f2e09073..a34c0065 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -339,9 +339,10 @@ end function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, opt) # treat segments - segments = iter_segments(series, series[:seriestype]) + segments = collect(series_segments(series, series[:seriestype])) sf = opt[:fillrange] - for (i, rng) in enumerate(segments) + for segment in segments + i, rng = segment.attr_index, segment.range segment_opt = PGFPlotsX.Options() segment_opt = merge(segment_opt, pgfx_linestyle(opt, i)) if opt[:markershape] != :none diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index ce2b704c..597413f2 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -643,7 +643,7 @@ function plotly_series(plt::Plot, series::Series) end function plotly_series_shapes(plt::Plot, series::Series, clims) - segments = iter_segments(series) + segments = collect(series_segments(series)) plotattributes_outs = Vector{KW}(undef, length(segments)) # TODO: create a plotattributes_out for each polygon @@ -662,7 +662,8 @@ function plotly_series_shapes(plt::Plot, series::Series, clims) for (letter, data) in zip((:x, :y), shape_data(series, 100)) ) - for (i,rng) in enumerate(segments) + for segment in segments + i, rng = segment.attr_index, segment.range length(rng) < 2 && continue # to draw polygons, we actually draw lines with fill @@ -705,14 +706,16 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z hasfillrange = st in (:path, :scatter, :scattergl, :straightline) && (isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], Tuple)) - segments = iter_segments(series, st) + segments = collect(series_segments(series, st)) plotattributes_outs = fill(KW(), (hasfillrange ? 2 : 1 ) * length(segments)) needs_scatter_fix = !isscatter && hasmarker && !any(isnan,y) && length(segments) > 1 - for (i,rng) in enumerate(segments) + for (k, segment) in enumerate(segments) + i, rng = segment.attr_index, segment.range + plotattributes_out = deepcopy(plotattributes_base) - plotattributes_out[:showlegend] = i==1 ? should_add_to_legend(series) : false + plotattributes_out[:showlegend] = k==1 ? should_add_to_legend(series) : false plotattributes_out[:legendgroup] = series[:label] # set the type @@ -805,9 +808,9 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z delete!(plotattributes_out, :fillcolor) end - plotattributes_outs[(2 * i - 1):(2 * i)] = [plotattributes_out_fillrange, plotattributes_out] + plotattributes_outs[(2k-1):(2k)] = [plotattributes_out_fillrange, plotattributes_out] else - plotattributes_outs[i] = plotattributes_out + plotattributes_outs[k] = plotattributes_out end end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 83899620..4c8ed18a 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -440,9 +440,10 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) # end # push!(handles, handle) # else - for (i, rng) in enumerate(iter_segments(series, st)) + for (k, segment) in enumerate(series_segments(series, st)) + i, rng = segment.attr_index, segment.range handle = ax."plot"((arg[rng] for arg in xyargs)...; - label = i == 1 ? series[:label] : "", + label = k == 1 ? series[:label] : "", zorder = series[:series_plotindex], color = py_color(single_color(get_linecolor(series, clims, i)), get_linealpha(series, i)), linewidth = py_thickness_scale(plt, get_linewidth(series, i)), @@ -486,7 +487,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) if series[:markershape] != :none && st in ( :path, :scatter, :path3d, :scatter3d, :steppre, :steppost, :bar ) - for (i, rng) in enumerate(iter_segments(series, :scatter)) + for segment in series_segments(series, :scatter) + i, rng = segment.attr_index, segment.range xyargs = if st == :bar && !isvertical(series) if RecipesPipeline.is3d(sp) y[rng], x[rng], z[rng] @@ -679,7 +681,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) if st == :shape handle = [] - for (i, rng) in enumerate(iter_segments(series)) + for segment in series_segments(series) + i, rng = segment.attr_index, segment.range if length(rng) > 1 path = pypath."Path"(hcat(x[rng], y[rng])) patches = pypatches."PathPatch"( @@ -706,7 +709,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) # handle area filling fillrange = series[:fillrange] if fillrange !== nothing && st != :contour - for (i, rng) in enumerate(iter_segments(series)) + for segment in series_segments(series) + i, rng = segment.attr_index, segment.range f, dim1, dim2 = if isvertical(series) :fill_between, x[rng], y[rng] else diff --git a/src/examples.jl b/src/examples.jl index b81f5789..1d5daecc 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -1031,13 +1031,26 @@ const _examples = PlotExample[ [quote yv = ones(9) ys = [1; 1; NaN; ones(6)] - plot( - 5 .- [yv 2ys 3yv 4ys], + y = 5 .- [yv 2ys 3yv 4ys] + + plt_color_rows = plot( + y, seriestype = [:path :path :scatter :scatter], markershape = [:utriangle, :rect], markersize = 8, color = [:red, :black], ) + + plt_z_cols = plot( + y, + markershape = [:utriangle :x :circle :square], + markersize = [5 10 10 5], + marker_z = [5 4 3 2], + line_z = [1 3 3 1], + linewidth = [1 10 5 1] + ) + + plot(plt_color_rows, plt_z_cols) end] ), PlotExample( # 49 diff --git a/src/utils.jl b/src/utils.jl index fc85923a..67fe5d61 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -53,10 +53,16 @@ function Base.push!(segments::Segments{T}, vs::AVec) where T end +struct SeriesSegment + # indexes of this segement in series data vectors + range::UnitRange + # index into vector-valued attributes corresponding to this segment + attr_index::Int +end + # ----------------------------------------------------- # helper to manage NaN-separated segments - -mutable struct SegmentsIterator +struct NaNSegmentsIterator args::Tuple n1::Int n2::Int @@ -66,28 +72,26 @@ function iter_segments(args...) tup = Plots.wraptuple(args) n1 = minimum(map(firstindex, tup)) n2 = maximum(map(lastindex, tup)) - SegmentsIterator(tup, n1, n2) + NaNSegmentsIterator(tup, n1, n2) end -function iter_segments(series::Series, seriestype::Symbol = :path) +function series_segments(series::Series, seriestype::Symbol = :path) x, y, z = series[:x], series[:y], series[:z] - if x === nothing - return UnitRange{Int}[] - elseif has_attribute_segments(series) - if any(isnan,y) - return [iter_segments(y)...] - elseif seriestype in (:scatter, :scatter3d) - return [[i] for i in eachindex(y)] - else - return [i:(i + 1) for i in firstindex(y):lastindex(y)-1] - end + x === nothing && return UnitRange{Int}[] + + args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y) + nan_segments = collect(iter_segments(args...)) + + if has_attribute_segments(series) + return Iterators.flatten(map(nan_segments) do r + if seriestype in (:scatter, :scatter3d) + (SeriesSegment(i:i, i) for i in r) + else + (SeriesSegment(i:i+1, i) for i in first(r):last(r)-1) + end + end) else - segs = UnitRange{Int}[] - args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y) - for seg in iter_segments(args...) - push!(segs, seg) - end - return segs + return (SeriesSegment(r, 1) for r in nan_segments) end end @@ -97,7 +101,7 @@ anynan(args::Tuple) = i -> anynan(i,args) 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::SegmentsIterator, nextidx::Int = itr.n1) +function Base.iterate(itr::NaNSegmentsIterator, nextidx::Int = itr.n1) i = findfirst(!anynan(itr.args), nextidx:itr.n2) i === nothing && return nothing nextval = nextidx + i - 1 @@ -107,6 +111,7 @@ function Base.iterate(itr::SegmentsIterator, nextidx::Int = itr.n1) nextval:nextnan-1, nextnan end +Base.IteratorSize(::NaNSegmentsIterator) = Base.SizeUnknown() # Find minimal type that can contain NaN and x # To allow use of NaN separated segments with categorical x axis @@ -575,13 +580,8 @@ end function has_attribute_segments(series::Series) # we want to check if a series needs to be split into segments just because # of its attributes - for letter in (:x, :y, :z) - # If we have NaNs in the data they define the segments and - # SegmentsIterator is used - series[letter] !== nothing && NaN in collect(series[letter]) && return false - end series[:seriestype] == :shape && return false - # ... else we check relevant attributes if they have multiple inputs + # check relevant attributes if they have multiple inputs return any( (typeof(series[attr]) <: AbstractVector && length(series[attr]) > 1) for diff --git a/test/runtests.jl b/test/runtests.jl index 09ec3a31..26797405 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -175,14 +175,8 @@ end @test_throws ArgumentError gif(anim) end -@testset "Segments" begin - function segments(args...) - segs = UnitRange{Int}[] - for seg in iter_segments(args...) - push!(segs,seg) - end - segs - end +@testset "NaN-separated Segments" begin + segments(args...) = collect(iter_segments(args...)) nan10 = fill(NaN,10) @test segments(11:20) == [1:10] From 164725079dcd6de4dff086d9c5edaa78ff031c59 Mon Sep 17 00:00:00 2001 From: yha Date: Thu, 25 Feb 2021 00:53:00 +0000 Subject: [PATCH 2/6] Update precompile_*.jl file --- .../precompile/precompile_Plots.jl | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/deps/SnoopCompile/precompile/precompile_Plots.jl b/deps/SnoopCompile/precompile/precompile_Plots.jl index dc95b6b4..8e5878b4 100644 --- a/deps/SnoopCompile/precompile/precompile_Plots.jl +++ b/deps/SnoopCompile/precompile/precompile_Plots.jl @@ -95,13 +95,12 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:marker, :series_annotations, :seriestype),Tuple{Tuple{Int64,Float64,Symbol},Array{Any,1},Symbol}},typeof(plot!),Plot{PlotlyBackend},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:marker, :series_annotations, :seriestype),Tuple{Tuple{Int64,Float64,Symbol},Array{Any,1},Symbol}},typeof(plot!),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:markersize, :c, :seriestype),Tuple{Int64,Symbol,Symbol}},typeof(plot!),Array{Float64,1}}) - Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:markersize, :c, :seriestype),Tuple{Int64,Symbol,Symbol}},typeof(plot!),Plot{GRBackend},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:seriestype, :inset),Tuple{Symbol,Tuple{Int64,BoundingBox{Tuple{Length{:w,Float64},Length{:h,Float64}},Tuple{Length{:w,Float64},Length{:h,Float64}}}}}},typeof(plot!),Array{Int64,1},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:seriestype, :inset),Tuple{Symbol,Tuple{Int64,BoundingBox{Tuple{Length{:w,Float64},Length{:h,Float64}},Tuple{Length{:w,Float64},Length{:h,Float64}}}}}},typeof(plot!),Plot{GRBackend},Array{Int64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:seriestype, :inset),Tuple{Symbol,Tuple{Int64,BoundingBox{Tuple{Length{:w,Float64},Length{:h,Float64}},Tuple{Length{:w,Float64},Length{:h,Float64}}}}}},typeof(plot!),Plot{PlotlyBackend},Array{Int64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot!),Array{Int64,1}}) - Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:title,),Tuple{String}},typeof(plot!),Plot{PlotlyBackend}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:title,),Tuple{String}},typeof(plot!)}) + Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:w,),Tuple{Int64}},typeof(plot!),Array{Float64,1},Array{Float64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:w,),Tuple{Int64}},typeof(plot!),Plot{GRBackend},Array{Float64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:xgrid,),Tuple{Tuple{Symbol,Symbol,Int64,Symbol,Float64}}},typeof(plot!),Plot{GRBackend}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:yaxis,),Tuple{Tuple{String,Symbol}}},typeof(plot!)}) @@ -109,6 +108,7 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:zcolor, :m, :ms, :lab, :seriestype),Tuple{Array{Float64,1},Tuple{Symbol,Float64,Stroke},Array{Float64,1},String,Symbol}},typeof(plot!),Plot{GRBackend},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:zcolor, :m, :ms, :lab, :seriestype),Tuple{Array{Float64,1},Tuple{Symbol,Float64,Stroke},Array{Float64,1},String,Symbol}},typeof(plot!),Plot{PlotlyBackend},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:annotations, :leg),Tuple{Tuple{Int64,Float64,PlotText},Bool}},typeof(plot),Array{Float64,1}}) + Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:arrow,),Tuple{Int64}},typeof(plot),Array{Float64,1},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:aspect_ratio, :seriestype),Tuple{Int64,Symbol}},typeof(plot),Array{String,1},Array{String,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:bins, :weights, :seriestype),Tuple{Symbol,Array{Int64,1},Symbol}},typeof(plot),Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:color, :line, :marker),Tuple{Array{Symbol,2},Tuple{Symbol,Int64},Tuple{Array{Symbol,2},Int64,Float64,Stroke}}},typeof(plot),Array{Array{T,1} where T,1}}) @@ -141,17 +141,21 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:m, :lab, :bg, :xlim, :ylim, :seriestype),Tuple{Tuple{Int64,Symbol},Array{String,2},Symbol,Tuple{Int64,Int64},Tuple{Int64,Int64},Symbol}},typeof(plot),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:marker,),Tuple{Bool}},typeof(plot),Array{Union{Missing, Int64},1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:marker_z, :color, :legend, :seriestype),Tuple{typeof(+),Symbol,Bool,Symbol}},typeof(plot),Array{Float64,1},Array{Float64,1}}) + Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:markershape, :markersize, :marker_z, :line_z, :linewidth),Tuple{Array{Symbol,2},Array{Int64,2},Array{Int64,2},Array{Int64,2},Array{Int64,2}}},typeof(plot),Array{Float64,2}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:nbins, :seriestype),Tuple{Int64,Symbol}},typeof(plot),Array{Float64,1},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:nbins, :show_empty_bins, :normed, :aspect_ratio, :seriestype),Tuple{Tuple{Int64,Int64},Bool,Bool,Int64,Symbol}},typeof(plot),Array{Complex{Float64},1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:proj, :m),Tuple{Symbol,Int64}},typeof(plot),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:projection, :seriestype),Tuple{Symbol,Symbol}},typeof(plot),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},UnitRange{Int64},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:quiver, :seriestype),Tuple{Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}},Symbol}},typeof(plot),Array{Float64,1},Array{Float64,1},Vararg{Array{Float64,1},N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:reg, :fill),Tuple{Bool,Tuple{Int64,Symbol}}},typeof(plot),Array{Float64,1}}) + Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{Int64}},typeof(plot),UnitRange{Int64}}) + Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}},typeof(plot),UnitRange{Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{Tuple{LinRange{Float64},LinRange{Float64}}}},typeof(plot),UnitRange{Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{typeof(sqrt)}},typeof(plot),UnitRange{Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype, :markershape, :markersize, :color),Tuple{Array{Symbol,2},Array{Symbol,1},Int64,Array{Symbol,1}}},typeof(plot),Array{Float64,2}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot),Array{DateTime,1},UnitRange{Int64},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot),Array{OHLC,1}}) + Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:st, :xlabel, :ylabel, :zlabel),Tuple{Symbol,String,String,String}},typeof(plot),Array{Float64,1},Array{Float64,1},Vararg{Array{Float64,1},N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:title, :l, :seriestype),Tuple{String,Float64,Symbol}},typeof(plot),Array{String,1},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:title,),Tuple{Array{String,2}}},typeof(plot),Plot{GRBackend},Plot{GRBackend}}) @@ -174,7 +178,6 @@ function _precompile_() Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},PortfolioComposition}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:barhist}},Any,Any,Any}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:bar}},Any,Any,Any}) - Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:bins2d}},Any,Any,Any}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:histogram2d}},Any,Any,Any}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:hline}},Any,Any,Any}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:pie}},Any,Any,Any}) @@ -182,12 +185,12 @@ function _precompile_() Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:spy}},Any,Any,Any}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:sticks}},Any,Any,Any}) Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol,Any},Type{Val{:xerror}},Any,Any,Any}) - Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Type{Val{:hline}},Plot{GRBackend}}) Base.precompile(Tuple{typeof(RecipesPipeline.add_series!),Plot{GRBackend},DefaultsDict}) Base.precompile(Tuple{typeof(RecipesPipeline.add_series!),Plot{PlotlyBackend},DefaultsDict}) Base.precompile(Tuple{typeof(RecipesPipeline.plot_setup!),Plot{GRBackend},Dict{Symbol,Any},Array{Dict{Symbol,Any},1}}) Base.precompile(Tuple{typeof(RecipesPipeline.plot_setup!),Plot{PlotlyBackend},Dict{Symbol,Any},Array{Dict{Symbol,Any},1}}) Base.precompile(Tuple{typeof(RecipesPipeline.preprocess_attributes!),Plot{GRBackend},DefaultsDict}) + Base.precompile(Tuple{typeof(RecipesPipeline.preprocess_axis_args!),Plot{GRBackend},Dict{Symbol,Any},Symbol}) Base.precompile(Tuple{typeof(RecipesPipeline.process_userrecipe!),Plot{GRBackend},Array{Dict{Symbol,Any},1},Dict{Symbol,Any}}) Base.precompile(Tuple{typeof(RecipesPipeline.process_userrecipe!),Plot{PlotlyBackend},Array{Dict{Symbol,Any},1},Dict{Symbol,Any}}) Base.precompile(Tuple{typeof(RecipesPipeline.warn_on_recipe_aliases!),Plot{GRBackend},DefaultsDict,Symbol,Any}) @@ -212,11 +215,9 @@ function _precompile_() Base.precompile(Tuple{typeof(_preprocess_barlike),DefaultsDict,Base.OneTo{Int64},Array{Float64,1}}) Base.precompile(Tuple{typeof(_preprocess_binlike),DefaultsDict,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1}}) Base.precompile(Tuple{typeof(_replace_markershape),Array{Symbol,1}}) - Base.precompile(Tuple{typeof(_slice_series_args!),DefaultsDict,Plot{GRBackend},Subplot{GRBackend},Int64}) Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout}) Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol,Any},Int64,Bool}) Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol,Any},Int64,Bool}) - Base.precompile(Tuple{typeof(allStyles),Symbol}) Base.precompile(Tuple{typeof(backend),PlotlyBackend}) Base.precompile(Tuple{typeof(bbox),Float64,Float64,Float64,Float64}) Base.precompile(Tuple{typeof(bbox),Length{:mm,Float64},Length{:mm,Float64},Length{:mm,Float64},Length{:mm,Float64}}) @@ -225,15 +226,16 @@ function _precompile_() Base.precompile(Tuple{typeof(convert_to_polar),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1},Tuple{Int64,Float64}}) Base.precompile(Tuple{typeof(create_grid),Expr}) Base.precompile(Tuple{typeof(error_coords),Array{Float64,1},Array{Float64,1},Array{Float64,1}}) + Base.precompile(Tuple{typeof(error_zipit),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}}}) Base.precompile(Tuple{typeof(fakedata),Int64,Vararg{Int64,N} where N}) Base.precompile(Tuple{typeof(font),String,Vararg{Any,N} where N}) - Base.precompile(Tuple{typeof(frame),Animation,Plot{GRBackend}}) Base.precompile(Tuple{typeof(get_clims),Subplot{GRBackend},Series,Function}) Base.precompile(Tuple{typeof(get_minor_ticks),Subplot{GRBackend},Axis,Tuple{Array{Float64,1},Array{String,1}}}) Base.precompile(Tuple{typeof(get_minor_ticks),Subplot{GRBackend},Axis,Tuple{Array{Int64,1},Array{String,1}}}) Base.precompile(Tuple{typeof(get_series_color),Array{Symbol,1},Subplot{GRBackend},Int64,Symbol}) Base.precompile(Tuple{typeof(get_series_color),Array{Symbol,1},Subplot{PlotlyBackend},Int64,Symbol}) Base.precompile(Tuple{typeof(get_xy),Array{OHLC,1}}) + Base.precompile(Tuple{typeof(get_xy),OHLC{Float64},Int64,Float64}) Base.precompile(Tuple{typeof(gr_add_legend),Subplot{GRBackend},NamedTuple{(:w, :h, :dy, :leftw, :textw, :rightw, :xoffset, :yoffset, :width_factor),NTuple{9,Float64}},Array{Float64,1}}) Base.precompile(Tuple{typeof(gr_add_legend),Subplot{GRBackend},NamedTuple{(:w, :h, :dy, :leftw, :textw, :rightw, :xoffset, :yoffset, :width_factor),Tuple{Int64,Float64,Float64,Float64,Int64,Float64,Float64,Float64,Float64}},Array{Float64,1}}) Base.precompile(Tuple{typeof(gr_display),Subplot{GRBackend},Length{:mm,Float64},Length{:mm,Float64},Array{Float64,1}}) @@ -241,21 +243,31 @@ function _precompile_() Base.precompile(Tuple{typeof(gr_draw_contour),Series,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_grid),Subplot{GRBackend},Axis,Segments{Tuple{Float64,Float64}}}) Base.precompile(Tuple{typeof(gr_draw_heatmap),Series,Array{Float64,1},Array{Float64,1},Array{Float64,2},Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_markers),Series,Array{Float64,1},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_markers),Series,Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_markers),Series,Array{Int64,1},Array{Int64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_markers),Series,Base.OneTo{Int64},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_markers),Series,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Float64,1},Array{Float64,1},Int64,Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Float64,1},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Int64,1},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,Base.OneTo{Int64},Array{Float64,1},Int64,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Base.OneTo{Int64},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,Base.OneTo{Int64},UnitRange{Int64},Tuple{Array{Float64,1},Array{Float64,1}},Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,StepRange{Int64,Int64},Array{Float64,1},Int64,Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_segments_3d),Series,Array{Float64,1},Array{Float64,1},Array{Float64,1},Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,UnitRange{Int64},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments_3d),Series,Array{Float64,1},Array{Float64,1},UnitRange{Int64},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_surface),Series,Array{Float64,1},Array{Float64,1},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_surface),Series,Array{Float64,1},Array{Float64,1},Array{Float64,2},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_get_ticks_size),Tuple{Array{Float64,1},Array{Any,1}},Int64}) Base.precompile(Tuple{typeof(gr_get_ticks_size),Tuple{Array{Float64,1},Array{String,1}},Int64}) Base.precompile(Tuple{typeof(gr_get_ticks_size),Tuple{Array{Int64,1},Array{String,1}},Int64}) + Base.precompile(Tuple{typeof(gr_label_ticks),Subplot{GRBackend},Symbol,Tuple{Array{Float64,1},Array{Any,1}}}) Base.precompile(Tuple{typeof(gr_label_ticks),Subplot{GRBackend},Symbol,Tuple{Array{Float64,1},Array{String,1}}}) Base.precompile(Tuple{typeof(gr_label_ticks_3d),Subplot{GRBackend},Symbol,Tuple{Array{Float64,1},Array{String,1}}}) Base.precompile(Tuple{typeof(gr_polaraxes),Int64,Float64,Subplot{GRBackend}}) + Base.precompile(Tuple{typeof(gr_polyline),Array{Float64,1},Array{Float64,1},Function}) Base.precompile(Tuple{typeof(gr_set_gradient),PlotUtils.ContinuousColorGradient}) Base.precompile(Tuple{typeof(gr_viewport_from_bbox),Subplot{GRBackend},BoundingBox{Tuple{Length{:mm,Float64},Length{:mm,Float64}},Tuple{Length{:mm,Float64},Length{:mm,Float64}}},Length{:mm,Float64},Length{:mm,Float64},Array{Float64,1}}) Base.precompile(Tuple{typeof(heatmap_edges),Array{Float64,1},Symbol}) @@ -263,18 +275,19 @@ function _precompile_() Base.precompile(Tuple{typeof(heatmap_edges),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Symbol}) Base.precompile(Tuple{typeof(heatmap_edges),UnitRange{Int64},Symbol}) Base.precompile(Tuple{typeof(ignorenan_minimum),Array{Int64,1}}) - Base.precompile(Tuple{typeof(iter_segments),Array{Float64,1},Array{Float64,1},UnitRange{Int64}}) - Base.precompile(Tuple{typeof(iter_segments),Base.OneTo{Int64},Array{Float64,1}}) Base.precompile(Tuple{typeof(layout_args),Int64}) Base.precompile(Tuple{typeof(make_fillrange_side),UnitRange{Int64},LinRange{Float64}}) + Base.precompile(Tuple{typeof(make_steps),Base.OneTo{Int64},Symbol}) Base.precompile(Tuple{typeof(optimal_ticks_and_labels),Subplot{GRBackend},Axis,StepRange{Int64,Int64}}) Base.precompile(Tuple{typeof(optimal_ticks_and_labels),Subplot{GRBackend},Axis,UnitRange{Int64}}) Base.precompile(Tuple{typeof(plot!),Any}) Base.precompile(Tuple{typeof(plot),Any,Any}) Base.precompile(Tuple{typeof(plot),Any}) Base.precompile(Tuple{typeof(processGridArg!),DefaultsDict,Bool,Symbol}) + Base.precompile(Tuple{typeof(processGridArg!),Dict{Symbol,Any},Int64,Symbol}) Base.precompile(Tuple{typeof(processGridArg!),Dict{Symbol,Any},Symbol,Symbol}) Base.precompile(Tuple{typeof(processLineArg),Dict{Symbol,Any},Array{Symbol,2}}) + Base.precompile(Tuple{typeof(processLineArg),Dict{Symbol,Any},Int64}) Base.precompile(Tuple{typeof(processLineArg),Dict{Symbol,Any},Symbol}) Base.precompile(Tuple{typeof(processMarkerArg),Dict{Symbol,Any},Array{Symbol,2}}) Base.precompile(Tuple{typeof(processMarkerArg),Dict{Symbol,Any},RGBA{Float64}}) @@ -290,6 +303,7 @@ function _precompile_() Base.precompile(Tuple{typeof(quiver_using_arrows),DefaultsDict}) Base.precompile(Tuple{typeof(quiver_using_hack),DefaultsDict}) Base.precompile(Tuple{typeof(reset_axis_defaults_byletter!)}) + Base.precompile(Tuple{typeof(slice_arg),Array{Int64,2},Int64}) Base.precompile(Tuple{typeof(slice_arg),Array{Length{:mm,Float64},2},Int64}) Base.precompile(Tuple{typeof(slice_arg),Array{PlotUtils.ContinuousColorGradient,2},Int64}) Base.precompile(Tuple{typeof(slice_arg),Array{RGBA{Float64},2},Int64}) @@ -301,11 +315,18 @@ function _precompile_() Base.precompile(Tuple{typeof(stroke),Int64,Vararg{Any,N} where N}) Base.precompile(Tuple{typeof(text),String,Int64,Symbol,Vararg{Symbol,N} where N}) Base.precompile(Tuple{typeof(text),String,Symbol,Int64,Vararg{Any,N} where N}) + Base.precompile(Tuple{typeof(text),String,Symbol}) Base.precompile(Tuple{typeof(title!),AbstractString}) Base.precompile(Tuple{typeof(unzip),Array{GeometryBasics.Point{2,Float64},1}}) Base.precompile(Tuple{typeof(vline!),Any}) Base.precompile(Tuple{typeof(xgrid!),Plot{GRBackend},Symbol,Vararg{Any,N} where N}) + Base.precompile(Tuple{typeof(xlims),Subplot{PlotlyBackend}}) Base.precompile(Tuple{typeof(yaxis!),Any,Any}) + let fbody = try __lookup_kwbody__(which(gr_polyline, (Array{Float64,1},Array{Float64,1},typeof(GR.fillarea),))) catch missing end + if !ismissing(fbody) + precompile(fbody, (Symbol,Symbol,typeof(gr_polyline),Array{Float64,1},Array{Float64,1},typeof(GR.fillarea),)) + end + end let fbody = try __lookup_kwbody__(which(plot!, ())) catch missing end if !ismissing(fbody) precompile(fbody, (Any,typeof(plot!),)) From e9cd69ea2ff3e663ab1101b3eec863a6fe1d110f Mon Sep 17 00:00:00 2001 From: yha Date: Mon, 1 Mar 2021 02:17:42 +0200 Subject: [PATCH 3/6] Fix Shape vector recipe --- src/components.jl | 12 ++++-------- src/recipes.jl | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components.jl b/src/components.jl index 00ca51e6..b0a76167 100644 --- a/src/components.jl +++ b/src/components.jl @@ -42,15 +42,11 @@ function coords(shape::Shape) shape.x, shape.y end +#coords(shapes::AVec{Shape}) = unzip(map(coords, shapes)) function coords(shapes::AVec{Shape}) - length(shapes) == 0 && return zeros(0), zeros(0) - xs = map(get_xs, shapes) - ys = map(get_ys, shapes) - x, y = map(copy, coords(shapes[1])) - for shape in shapes[2:end] - nanappend!(x, shape.x) - nanappend!(y, shape.y) - end + c = map(coords, shapes) + x = [q[1] for q in c] + y = [q[2] for q in c] x, y end diff --git a/src/recipes.jl b/src/recipes.jl index 46ef79a1..dcf5fc8d 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1364,6 +1364,16 @@ end @recipe function f(shapes::AVec{Shape}) seriestype --> :shape + # For backwards compatibility, column vectors of segmenting attributes are + # interpreted as having one element per shape + for attr in union(_segmenting_array_attributes, _segmenting_vector_attributes) + v = get(plotattributes, attr, nothing) + if v isa AVec || v isa AMat && size(v,2) == 1 + @warn "Column vector attribute `$attr` reinterpreted as row vector (one value per shape).\n" * + "Pass a row vector instead (e.g. using `permutedims`) to suppress this warning." + plotattributes[attr] = permutedims(v) + end + end coords(shapes) end From 6af91c7f71cbe9bb0f310be2845873cb16ace845 Mon Sep 17 00:00:00 2001 From: yha Date: Mon, 1 Mar 2021 03:23:19 +0200 Subject: [PATCH 4/6] warning and hint on mismatched attr lengths --- src/utils.jl | 72 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 67fe5d61..8c4f8481 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -82,8 +82,8 @@ function series_segments(series::Series, seriestype::Symbol = :path) args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y) nan_segments = collect(iter_segments(args...)) - if has_attribute_segments(series) - return Iterators.flatten(map(nan_segments) do r + result = if has_attribute_segments(series) + Iterators.flatten(map(nan_segments) do r if seriestype in (:scatter, :scatter3d) (SeriesSegment(i:i, i) for i in r) else @@ -91,8 +91,28 @@ function series_segments(series::Series, seriestype::Symbol = :path) end end) else - return (SeriesSegment(r, 1) for r in nan_segments) + (SeriesSegment(r, 1) for r in nan_segments) + end + + seg_attr_range = UnitRange(minimum(first(seg.range) for seg in result), + maximum(last(seg.range) for seg in result)) + for attr in _segmenting_vector_attributes + v = get(series, attr, nothing) + if v isa AVec && eachindex(v) != seg_attr_range + @warn "Indices $(eachindex(v)) of attribute `$attr` does not match data indices $seg_attr_range." + if any(v -> !isnothing(v) && any(isnan, v), (x,y,z)) + @info """Data contains NaNs or missing values, and indices of `$attr` vector do not match data indices. + If you intend elements of `$attr` to apply to individual NaN-separated segements in the data, + pass each segment in a separate vector instead, and use a row vector for `$attr`. Legend entries + may be suppressed by passing an empty label. + For example, + plot([1:2,1:3], [[4,5],[3,4,5]], label=["y" ""], $attr=[1 2]) + """ + end + end end + + return result end # helpers to figure out if there are NaN values in a list of array types @@ -577,34 +597,34 @@ function get_markerstrokewidth(series, i::Int = 1) _cycle(series[:markerstrokewidth], i) end +const _segmenting_vector_attributes = ( + :seriescolor, + :seriesalpha, + :linecolor, + :linealpha, + :linewidth, + :linestyle, + :fillcolor, + :fillalpha, + :markercolor, + :markeralpha, + :markersize, + :markerstrokecolor, + :markerstrokealpha, + :markerstrokewidth, + :markershape, +) + +const _segmenting_array_attributes = (:line_z, :fill_z, :marker_z) + function has_attribute_segments(series::Series) # we want to check if a series needs to be split into segments just because # of its attributes series[:seriestype] == :shape && return false # check relevant attributes if they have multiple inputs - return any( - (typeof(series[attr]) <: AbstractVector && length(series[attr]) > 1) - for - attr in [ - :seriescolor, - :seriesalpha, - :linecolor, - :linealpha, - :linewidth, - :linestyle, - :fillcolor, - :fillalpha, - :markercolor, - :markeralpha, - :markersize, - :markerstrokecolor, - :markerstrokealpha, - :markerstrokewidth, - :markershape, - ] - ) || any( - typeof(series[attr]) <: AbstractArray for attr in (:line_z, :fill_z, :marker_z) - ) + return any(series[attr] isa AbstractVector && length(series[attr]) > 1 + for attr in _segmenting_vector_attributes + ) || any(series[attr] isa AbstractArray for attr in _segmenting_array_attributes) end function get_aspect_ratio(sp) From 97caa18fb44c70cfaa1dbdea4591b9699697a6a7 Mon Sep 17 00:00:00 2001 From: yha Date: Mon, 1 Mar 2021 01:33:16 +0000 Subject: [PATCH 5/6] Update precompile_*.jl file --- .../precompile/precompile_Plots.jl | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/deps/SnoopCompile/precompile/precompile_Plots.jl b/deps/SnoopCompile/precompile/precompile_Plots.jl index 8e5878b4..9e207e82 100644 --- a/deps/SnoopCompile/precompile/precompile_Plots.jl +++ b/deps/SnoopCompile/precompile/precompile_Plots.jl @@ -59,9 +59,9 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:parent,),Tuple{Subplot{PlotlyBackend}}},Type{Subplot},PlotlyBackend}) Base.precompile(Tuple{Core.kwftype(typeof(_make_hist)),NamedTuple{(:normed, :weights),Tuple{Bool,Array{Int64,1}}},typeof(_make_hist),Tuple{Array{Float64,1}},Symbol}) Base.precompile(Tuple{Core.kwftype(typeof(_make_hist)),NamedTuple{(:normed, :weights),Tuple{Bool,Nothing}},typeof(_make_hist),Tuple{Array{Float64,1},Array{Float64,1}},Int64}) + Base.precompile(Tuple{Core.kwftype(typeof(_make_hist)),NamedTuple{(:normed, :weights),Tuple{Bool,Nothing}},typeof(_make_hist),Tuple{Array{Float64,1},Array{Float64,1}},Tuple{Int64,Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(_make_hist)),NamedTuple{(:normed, :weights),Tuple{Bool,Nothing}},typeof(_make_hist),Tuple{Array{Float64,1}},Symbol}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:flip,),Tuple{Bool}},typeof(attr!),Axis}) - Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:formatter,),Tuple{Symbol}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:formatter,),Tuple{typeof(datetimeformatter)}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:grid, :lims),Tuple{Bool,Tuple{Float64,Float64}}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:grid, :lims, :flip),Tuple{Bool,Tuple{Float64,Float64},Bool}},typeof(attr!),Axis}) @@ -74,7 +74,6 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:lims,),Tuple{Tuple{Int64,Int64}}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:rotation,),Tuple{Int64}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:scale, :guide),Tuple{Symbol,String}},typeof(attr!),Axis}) - Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:ticks,),Tuple{Nothing}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(attr!)),NamedTuple{(:ticks,),Tuple{UnitRange{Int64}}},typeof(attr!),Axis}) Base.precompile(Tuple{Core.kwftype(typeof(default)),NamedTuple{(:titlefont, :legendfontsize, :guidefont, :tickfont, :guide, :framestyle, :yminorgrid),Tuple{Tuple{Int64,String},Int64,Tuple{Int64,Symbol},Tuple{Int64,Symbol},String,Symbol,Bool}},typeof(default)}) Base.precompile(Tuple{Core.kwftype(typeof(gr_polyline)),NamedTuple{(:arrowside, :arrowstyle),Tuple{Symbol,Symbol}},typeof(gr_polyline),Array{Int64,1},Array{Float64,1}}) @@ -100,7 +99,6 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:seriestype, :inset),Tuple{Symbol,Tuple{Int64,BoundingBox{Tuple{Length{:w,Float64},Length{:h,Float64}},Tuple{Length{:w,Float64},Length{:h,Float64}}}}}},typeof(plot!),Plot{PlotlyBackend},Array{Int64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot!),Array{Int64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:title,),Tuple{String}},typeof(plot!)}) - Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:w,),Tuple{Int64}},typeof(plot!),Array{Float64,1},Array{Float64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:w,),Tuple{Int64}},typeof(plot!),Plot{GRBackend},Array{Float64,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:xgrid,),Tuple{Tuple{Symbol,Symbol,Int64,Symbol,Float64}}},typeof(plot!),Plot{GRBackend}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:yaxis,),Tuple{Tuple{String,Symbol}}},typeof(plot!)}) @@ -108,7 +106,6 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:zcolor, :m, :ms, :lab, :seriestype),Tuple{Array{Float64,1},Tuple{Symbol,Float64,Stroke},Array{Float64,1},String,Symbol}},typeof(plot!),Plot{GRBackend},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:zcolor, :m, :ms, :lab, :seriestype),Tuple{Array{Float64,1},Tuple{Symbol,Float64,Stroke},Array{Float64,1},String,Symbol}},typeof(plot!),Plot{PlotlyBackend},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:annotations, :leg),Tuple{Tuple{Int64,Float64,PlotText},Bool}},typeof(plot),Array{Float64,1}}) - Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:arrow,),Tuple{Int64}},typeof(plot),Array{Float64,1},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:aspect_ratio, :seriestype),Tuple{Int64,Symbol}},typeof(plot),Array{String,1},Array{String,1},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:bins, :weights, :seriestype),Tuple{Symbol,Array{Int64,1},Symbol}},typeof(plot),Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:color, :line, :marker),Tuple{Array{Symbol,2},Tuple{Symbol,Int64},Tuple{Array{Symbol,2},Int64,Float64,Stroke}}},typeof(plot),Array{Array{T,1} where T,1}}) @@ -149,13 +146,11 @@ function _precompile_() Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:quiver, :seriestype),Tuple{Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}},Symbol}},typeof(plot),Array{Float64,1},Array{Float64,1},Vararg{Array{Float64,1},N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:reg, :fill),Tuple{Bool,Tuple{Int64,Symbol}}},typeof(plot),Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{Int64}},typeof(plot),UnitRange{Int64}}) - Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}},typeof(plot),UnitRange{Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{Tuple{LinRange{Float64},LinRange{Float64}}}},typeof(plot),UnitRange{Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:ribbon,),Tuple{typeof(sqrt)}},typeof(plot),UnitRange{Int64}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype, :markershape, :markersize, :color),Tuple{Array{Symbol,2},Array{Symbol,1},Int64,Array{Symbol,1}}},typeof(plot),Array{Float64,2}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot),Array{DateTime,1},UnitRange{Int64},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot),Array{OHLC,1}}) - Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:seriestype,),Tuple{Symbol}},typeof(plot),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Vararg{Any,N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:st, :xlabel, :ylabel, :zlabel),Tuple{Symbol,String,String,String}},typeof(plot),Array{Float64,1},Array{Float64,1},Vararg{Array{Float64,1},N} where N}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:title, :l, :seriestype),Tuple{String,Float64,Symbol}},typeof(plot),Array{String,1},Array{Float64,1}}) Base.precompile(Tuple{Core.kwftype(typeof(plot)),NamedTuple{(:title,),Tuple{Array{String,2}}},typeof(plot),Plot{GRBackend},Plot{GRBackend}}) @@ -190,7 +185,6 @@ function _precompile_() Base.precompile(Tuple{typeof(RecipesPipeline.plot_setup!),Plot{GRBackend},Dict{Symbol,Any},Array{Dict{Symbol,Any},1}}) Base.precompile(Tuple{typeof(RecipesPipeline.plot_setup!),Plot{PlotlyBackend},Dict{Symbol,Any},Array{Dict{Symbol,Any},1}}) Base.precompile(Tuple{typeof(RecipesPipeline.preprocess_attributes!),Plot{GRBackend},DefaultsDict}) - Base.precompile(Tuple{typeof(RecipesPipeline.preprocess_axis_args!),Plot{GRBackend},Dict{Symbol,Any},Symbol}) Base.precompile(Tuple{typeof(RecipesPipeline.process_userrecipe!),Plot{GRBackend},Array{Dict{Symbol,Any},1},Dict{Symbol,Any}}) Base.precompile(Tuple{typeof(RecipesPipeline.process_userrecipe!),Plot{PlotlyBackend},Array{Dict{Symbol,Any},1},Dict{Symbol,Any}}) Base.precompile(Tuple{typeof(RecipesPipeline.warn_on_recipe_aliases!),Plot{GRBackend},DefaultsDict,Symbol,Any}) @@ -235,7 +229,6 @@ function _precompile_() Base.precompile(Tuple{typeof(get_series_color),Array{Symbol,1},Subplot{GRBackend},Int64,Symbol}) Base.precompile(Tuple{typeof(get_series_color),Array{Symbol,1},Subplot{PlotlyBackend},Int64,Symbol}) Base.precompile(Tuple{typeof(get_xy),Array{OHLC,1}}) - Base.precompile(Tuple{typeof(get_xy),OHLC{Float64},Int64,Float64}) Base.precompile(Tuple{typeof(gr_add_legend),Subplot{GRBackend},NamedTuple{(:w, :h, :dy, :leftw, :textw, :rightw, :xoffset, :yoffset, :width_factor),NTuple{9,Float64}},Array{Float64,1}}) Base.precompile(Tuple{typeof(gr_add_legend),Subplot{GRBackend},NamedTuple{(:w, :h, :dy, :leftw, :textw, :rightw, :xoffset, :yoffset, :width_factor),Tuple{Int64,Float64,Float64,Float64,Int64,Float64,Float64,Float64,Float64}},Array{Float64,1}}) Base.precompile(Tuple{typeof(gr_display),Subplot{GRBackend},Length{:mm,Float64},Length{:mm,Float64},Array{Float64,1}}) @@ -243,33 +236,25 @@ function _precompile_() Base.precompile(Tuple{typeof(gr_draw_contour),Series,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_grid),Subplot{GRBackend},Axis,Segments{Tuple{Float64,Float64}}}) Base.precompile(Tuple{typeof(gr_draw_heatmap),Series,Array{Float64,1},Array{Float64,1},Array{Float64,2},Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_markers),Series,Array{Float64,1},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_markers),Series,Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_markers),Series,Array{Int64,1},Array{Int64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_markers),Series,Base.OneTo{Int64},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_markers),Series,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Float64,1},Array{Float64,1},Int64,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Float64,1},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Int64,1},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) + Base.precompile(Tuple{typeof(gr_draw_segments),Series,Array{Int64,1},Array{Int64,1},Nothing,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Base.OneTo{Int64},Array{Float64,1},Int64,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Base.OneTo{Int64},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,Base.OneTo{Int64},UnitRange{Int64},Tuple{Array{Float64,1},Array{Float64,1}},Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_segments),Series,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_segments),Series,StepRange{Int64,Int64},Array{Float64,1},Int64,Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_segments),Series,UnitRange{Int64},Array{Float64,1},Nothing,Tuple{Float64,Float64}}) - Base.precompile(Tuple{typeof(gr_draw_segments_3d),Series,Array{Float64,1},Array{Float64,1},UnitRange{Int64},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_surface),Series,Array{Float64,1},Array{Float64,1},Array{Float64,1},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_draw_surface),Series,Array{Float64,1},Array{Float64,1},Array{Float64,2},Tuple{Float64,Float64}}) Base.precompile(Tuple{typeof(gr_get_ticks_size),Tuple{Array{Float64,1},Array{Any,1}},Int64}) Base.precompile(Tuple{typeof(gr_get_ticks_size),Tuple{Array{Float64,1},Array{String,1}},Int64}) Base.precompile(Tuple{typeof(gr_get_ticks_size),Tuple{Array{Int64,1},Array{String,1}},Int64}) - Base.precompile(Tuple{typeof(gr_label_ticks),Subplot{GRBackend},Symbol,Tuple{Array{Float64,1},Array{Any,1}}}) Base.precompile(Tuple{typeof(gr_label_ticks),Subplot{GRBackend},Symbol,Tuple{Array{Float64,1},Array{String,1}}}) Base.precompile(Tuple{typeof(gr_label_ticks_3d),Subplot{GRBackend},Symbol,Tuple{Array{Float64,1},Array{String,1}}}) Base.precompile(Tuple{typeof(gr_polaraxes),Int64,Float64,Subplot{GRBackend}}) - Base.precompile(Tuple{typeof(gr_polyline),Array{Float64,1},Array{Float64,1},Function}) Base.precompile(Tuple{typeof(gr_set_gradient),PlotUtils.ContinuousColorGradient}) - Base.precompile(Tuple{typeof(gr_viewport_from_bbox),Subplot{GRBackend},BoundingBox{Tuple{Length{:mm,Float64},Length{:mm,Float64}},Tuple{Length{:mm,Float64},Length{:mm,Float64}}},Length{:mm,Float64},Length{:mm,Float64},Array{Float64,1}}) Base.precompile(Tuple{typeof(heatmap_edges),Array{Float64,1},Symbol}) Base.precompile(Tuple{typeof(heatmap_edges),Base.OneTo{Int64},Symbol}) Base.precompile(Tuple{typeof(heatmap_edges),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Symbol}) @@ -277,14 +262,12 @@ function _precompile_() Base.precompile(Tuple{typeof(ignorenan_minimum),Array{Int64,1}}) Base.precompile(Tuple{typeof(layout_args),Int64}) Base.precompile(Tuple{typeof(make_fillrange_side),UnitRange{Int64},LinRange{Float64}}) - Base.precompile(Tuple{typeof(make_steps),Base.OneTo{Int64},Symbol}) Base.precompile(Tuple{typeof(optimal_ticks_and_labels),Subplot{GRBackend},Axis,StepRange{Int64,Int64}}) Base.precompile(Tuple{typeof(optimal_ticks_and_labels),Subplot{GRBackend},Axis,UnitRange{Int64}}) Base.precompile(Tuple{typeof(plot!),Any}) Base.precompile(Tuple{typeof(plot),Any,Any}) Base.precompile(Tuple{typeof(plot),Any}) Base.precompile(Tuple{typeof(processGridArg!),DefaultsDict,Bool,Symbol}) - Base.precompile(Tuple{typeof(processGridArg!),Dict{Symbol,Any},Int64,Symbol}) Base.precompile(Tuple{typeof(processGridArg!),Dict{Symbol,Any},Symbol,Symbol}) Base.precompile(Tuple{typeof(processLineArg),Dict{Symbol,Any},Array{Symbol,2}}) Base.precompile(Tuple{typeof(processLineArg),Dict{Symbol,Any},Int64}) @@ -315,12 +298,10 @@ function _precompile_() Base.precompile(Tuple{typeof(stroke),Int64,Vararg{Any,N} where N}) Base.precompile(Tuple{typeof(text),String,Int64,Symbol,Vararg{Symbol,N} where N}) Base.precompile(Tuple{typeof(text),String,Symbol,Int64,Vararg{Any,N} where N}) - Base.precompile(Tuple{typeof(text),String,Symbol}) Base.precompile(Tuple{typeof(title!),AbstractString}) Base.precompile(Tuple{typeof(unzip),Array{GeometryBasics.Point{2,Float64},1}}) Base.precompile(Tuple{typeof(vline!),Any}) Base.precompile(Tuple{typeof(xgrid!),Plot{GRBackend},Symbol,Vararg{Any,N} where N}) - Base.precompile(Tuple{typeof(xlims),Subplot{PlotlyBackend}}) Base.precompile(Tuple{typeof(yaxis!),Any,Any}) let fbody = try __lookup_kwbody__(which(gr_polyline, (Array{Float64,1},Array{Float64,1},typeof(GR.fillarea),))) catch missing end if !ismissing(fbody) From c8b882d17ad941df27dd94829f4bee129dad292a Mon Sep 17 00:00:00 2001 From: yha Date: Tue, 2 Mar 2021 22:56:56 +0200 Subject: [PATCH 6/6] rename local var --- src/utils.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 8c4f8481..a23a47b3 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -94,12 +94,12 @@ function series_segments(series::Series, seriestype::Symbol = :path) (SeriesSegment(r, 1) for r in nan_segments) end - seg_attr_range = UnitRange(minimum(first(seg.range) for seg in result), + seg_range = UnitRange(minimum(first(seg.range) for seg in result), maximum(last(seg.range) for seg in result)) for attr in _segmenting_vector_attributes v = get(series, attr, nothing) - if v isa AVec && eachindex(v) != seg_attr_range - @warn "Indices $(eachindex(v)) of attribute `$attr` does not match data indices $seg_attr_range." + if v isa AVec && eachindex(v) != seg_range + @warn "Indices $(eachindex(v)) of attribute `$attr` does not match data indices $seg_range." if any(v -> !isnothing(v) && any(isnan, v), (x,y,z)) @info """Data contains NaNs or missing values, and indices of `$attr` vector do not match data indices. If you intend elements of `$attr` to apply to individual NaN-separated segements in the data,