Skip to content

Commit

Permalink
Merge pull request #2204 from BeastyBlacksmith/bbs/adapted_grid-change
Browse files Browse the repository at this point in the history
Update adapted_grid recipes
  • Loading branch information
mkborregaard authored Oct 8, 2019
2 parents 07ffa8c + 62fe5d0 commit a55f8d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,20 +515,24 @@ end
# # special handling... xmin/xmax with parametric function(s)
@recipe function f(f::Function, xmin::Number, xmax::Number)
xscale, yscale = [get(plotattributes, sym, :identity) for sym=(:xscale,:yscale)]
xs = _scaled_adapted_grid(f, xscale, yscale, xmin, xmax)
xs, f
_scaled_adapted_grid(f, xscale, yscale, xmin, xmax)
end
@recipe function f(fs::AbstractArray{F}, xmin::Number, xmax::Number) where F<:Function
xscale, yscale = [get(plotattributes, sym, :identity) for sym=(:xscale,:yscale)]
xs = Any[_scaled_adapted_grid(f, xscale, yscale, xmin, xmax) for f in fs]
xs, fs
xs = ys = Array{Any}(undef, length(fs))
for (i, (x, y)) in enumerate(_scaled_adapted_grid(f, xscale, yscale, xmin, xmax) for f in fs)
xs[i] = x
ys[i] = y
end
xs, ys
end
@recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, u::AVec) where {F<:Function,G<:Function} = mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u)
@recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, umin::Number, umax::Number, n = 200) where {F<:Function,G<:Function} = fx, fy, range(umin, stop = umax, length = n)

function _scaled_adapted_grid(f, xscale, yscale, xmin, xmax)
(xf, xinv), (yf, yinv) = ((scalefunc(s),invscalefunc(s)) for s in (xscale,yscale))
xinv.(adapted_grid(yffxinv, xf.((xmin, xmax))))
xs, ys = adapted_grid(yffxinv, xf.((xmin, xmax)))
xinv.(xs), yinv.(ys)
end

#
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ end
for plt in plots
display(plt)
end
@test_nowarn plot(x->x^2,0,2)
end

@testset "EmptyAnim" begin
Expand Down

0 comments on commit a55f8d0

Please sign in to comment.