JuliaApproximation / ContinuumArrays.jl

A package for representing quasi arrays with continuous indices
MIT License
27 stars 6 forks source link

Plot quasivector #145

Open putianyi889 opened 1 year ago

putianyi889 commented 1 year ago
julia> plot(Inclusion(-1..1))
ERROR: Overload Grid
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] _grid(#unused#::QuasiArrays.PolynomialLayout, P::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, n::Int64)
    @ ContinuumArrays C:\Users\pty\.julia\packages\ContinuumArrays\pWRm2\src\bases\bases.jl:154
  [3] grid(P::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, n::Int64)
    @ ContinuumArrays C:\Users\pty\.julia\packages\ContinuumArrays\pWRm2\src\bases\bases.jl:170
  [4] _plotgrid(lay::QuasiArrays.PolynomialLayout, P::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}}, n::Int64) (repeats 2 times)
    @ ContinuumArrays C:\Users\pty\.julia\packages\ContinuumArrays\pWRm2\src\plotting.jl:14
  [5] plotgrid(::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}})
    @ ContinuumArrays C:\Users\pty\.julia\packages\ContinuumArrays\pWRm2\src\plotting.jl:13
  [6] plotgridvalues(g::Inclusion{Float64, IntervalSets.ClosedInterval{Int64}})
    @ ContinuumArrays C:\Users\pty\.julia\packages\ContinuumArrays\pWRm2\src\plotting.jl:38
  [7] macro expansion
    @ C:\Users\pty\.julia\packages\ContinuumArrays\pWRm2\src\plotting.jl:43 [inlined]
  [8] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, g::QuasiArrays.AbstractQuasiArray)
    @ ContinuumArrays C:\Users\pty\.julia\packages\RecipesBase\z10lo\src\RecipesBase.jl:300
  [9] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline C:\Users\pty\.julia\packages\RecipesPipeline\XxUHt\src\user_recipe.jl:38
 [10] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline C:\Users\pty\.julia\packages\RecipesPipeline\XxUHt\src\RecipesPipeline.jl:72
 [11] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots C:\Users\pty\.julia\packages\Plots\9Q9pN\src\plot.jl:223
 [12] plot(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots C:\Users\pty\.julia\packages\Plots\9Q9pN\src\plot.jl:102
 [13] plot(args::Any)
    @ Plots C:\Users\pty\.julia\packages\Plots\9Q9pN\src\plot.jl:93
 [14] top-level scope
    @ REPL[12]:1
dlfivefifty commented 1 year ago

OK this will take some thought. Essentially it knows its a polynomial. I forget if I implemented the notion of degree but if we did we would be able to know how many points to take in the plotgrid. An evenly spaced grid could be fine here.

putianyi889 commented 1 year ago

I would also want it to work for arbitrary quasivectors, considering them as functions with known domain.

dlfivefifty commented 1 year ago

Yes that would make sense to have a generic backup with say 1000 points

putianyi889 commented 1 year ago

It could fall back to plotting functions, something like

plot(v::quasivector)=plot(x->v[x])

but I don't know which layer should this be implemented.

dlfivefifty commented 1 year ago

If you look at sum and sum_layout that auto-expands that gives a possible way of doing this