Mercurial > repos > public > sbplib_julia
comparison ext/DiffinitivePlotsExt.jl @ 2057:8a2a0d678d6f feature/lazy_tensors/pretty_printing
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 10 Feb 2026 22:41:19 +0100 |
| parents | 2d6c45f53bc9 |
| children |
comparison
equal
deleted
inserted
replaced
| 1110:c0bff9f6e0fb | 2057:8a2a0d678d6f |
|---|---|
| 1 module DiffinitivePlotsExt | |
| 2 | |
| 3 using Diffinitive.Grids | |
| 4 using Plots | |
| 5 | |
| 6 @recipe f(::Type{<:Grid}, g::Grid) = map(Tuple,g)[:] | |
| 7 | |
| 8 @recipe function f(c::Chart{2,<:Rectangle}, n=5, m=n; draw_border=true, bordercolor=1) | |
| 9 Ξ = parameterspace(c) | |
| 10 ξs = range(limits(Ξ,1)..., n) | |
| 11 ηs = range(limits(Ξ,2)..., m) | |
| 12 | |
| 13 label := false | |
| 14 seriescolor --> 2 | |
| 15 for ξ ∈ ξs | |
| 16 @series adapted_curve_grid(η->c((ξ,η)),limits(Ξ,1)) | |
| 17 end | |
| 18 | |
| 19 for η ∈ ηs | |
| 20 @series adapted_curve_grid(ξ->c((ξ,η)),limits(Ξ,2)) | |
| 21 end | |
| 22 | |
| 23 if ~draw_border | |
| 24 return | |
| 25 end | |
| 26 | |
| 27 for ξ ∈ limits(Ξ,1) | |
| 28 @series begin | |
| 29 linewidth --> 3 | |
| 30 seriescolor := bordercolor | |
| 31 adapted_curve_grid(η->c((ξ,η)),limits(Ξ,1)) | |
| 32 end | |
| 33 end | |
| 34 | |
| 35 for η ∈ limits(Ξ,2) | |
| 36 @series begin | |
| 37 linewidth --> 3 | |
| 38 seriescolor := bordercolor | |
| 39 adapted_curve_grid(ξ->c((ξ,η)),limits(Ξ,2)) | |
| 40 end | |
| 41 end | |
| 42 end | |
| 43 | |
| 44 function adapted_curve_grid(g, minmax) | |
| 45 t1, _ = PlotUtils.adapted_grid(t->g(t)[1], minmax) | |
| 46 t2, _ = PlotUtils.adapted_grid(t->g(t)[2], minmax) | |
| 47 | |
| 48 ts = sort(vcat(t1,t2)) | |
| 49 | |
| 50 x = map(ts) do t | |
| 51 g(t)[1] | |
| 52 end | |
| 53 y = map(ts) do t | |
| 54 g(t)[2] | |
| 55 end | |
| 56 | |
| 57 return x, y | |
| 58 end | |
| 59 | |
| 60 end |
