Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Nov 8, 2022
1 parent 139f617 commit ae59955
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
28 changes: 7 additions & 21 deletions src/pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,12 @@ function RecipesPipeline.plot_setup!(plt::Plot, plotattributes, kw_list)
end

function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_list)
min_x = min_y = min_z = +Inf
max_x = max_y = max_z = -Inf

# determine global extrema
ex = ey = ez = +Inf, -Inf
for kw in kw_list
if (x = kw[:x]) nothing
mn, mx = extrema(x)
min_x = NaNMath.min(min_x, mn)
max_x = NaNMath.max(max_x, mx)
end
if (y = kw[:y]) nothing
mn, mx = extrema(y)
min_y = NaNMath.min(min_y, mn)
max_y = NaNMath.max(max_y, mx)
end
if (z = kw[:z]) nothing
mn, mx = extrema(z)
min_z = NaNMath.min(min_z, mn)
max_z = NaNMath.max(max_z, mx)
end
ex = nan_min_max(kw[:x], ex)
ey = nan_min_max(kw[:y], ey)
ez = nan_min_max(kw[:z], ez)
end

# swap errors
Expand All @@ -185,9 +171,9 @@ function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_l
end

for kw in kw_list
kw[:ex] = min_x, max_x
kw[:ey] = min_y, max_y
kw[:ez] = min_z, max_z
kw[:ex] = ex
kw[:ey] = ey
kw[:ez] = ez

rib = get(kw, :ribbon, default(:ribbon))
fr = get(kw, :fillrange, default(:fillrange))
Expand Down
6 changes: 6 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ function iter_segments(args...)
NaNSegmentsIterator(tup, n1, n2)
end

nan_min_max(::Any, ::Any) = nothing
function nan_min_max(x::AbstractArray{<:Number}, ex)
mn, mx = extrema(x)
NaNMath.min(ex[1], mn), NaNMath.max(ex[2], mx)
end

function series_segments(series::Series, seriestype::Symbol = :path; check = false)
x, y, z = series[:x], series[:y], series[:z]
(x === nothing || isempty(x)) && return UnitRange{Int}[]
Expand Down

0 comments on commit ae59955

Please sign in to comment.