Closed asinghvi17 closed 5 months ago
Ok, made some decent progress here! The recipes are now to the point that they can plot any DiffEq solution to any point-based plot type, depending on what the user provides. Color cycling also comes naturally and is affected by theme.
On the Makie level, it's currently not supported to pass themes from the plot invocation to subsidiary recipes unless they are specified and consumed, so you can't adjust things like linewidth
in the plot
call (though you can do that in the global theme, which does trickle down). Once that's solved on the Makie end it should be a relatively simple update here.
I also added basic support for ensembles, which seem to be the only things which had special treatment in SciMLBase's Plots recipes so far.
Here are some examples
A basic plot
Support for a random recipe which is defined as consuming point-based input
Theming :)
Ensemble
Ensemble with errorbars
I also added basic support for ensembles, which seem to be the only things which had special treatment in SciMLBase's Plots recipes so far.
Integrators have a recipe as well
I think this looks good?
Attention: 134 lines
in your changes are missing coverage. Please review.
Comparison is base (
48771ae
) 40.16% compared to head (0636e40
) 38.91%. Report is 2 commits behind head on master.:exclamation: Current head 0636e40 differs from pull request most recent head 57890b3. Consider uploading reports for the commit 57890b3 to get more accurate results
Files | Patch % | Lines |
---|---|---|
ext/SciMLBaseMakieExt.jl | 0.00% | 133 Missing :warning: |
src/ensemble/ensemble_solutions.jl | 0.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
It should work for most simple usecases - more advanced ones will probably need to be deconstructed manually, but that's not particularly hard...
That's fine, it's a start. We can get it in there and let it keep improving.
I have a question about the recipe, but I am not sure if this is the right place to ask @asinghvi17 . Say if I want to scale the axis (e.g. time) by a factor of 10 for plotting, how should I do that? Makie provides a function scale!
; it works for a simple case like
f = Figure()
ax = Axis(f[1, 1], aspect=1)
l0 = lines!(ax, [0, 1], [0, 1])
scale!(l0, 10, 1)
but not for the DiffEq recipe:
using OrdinaryDiffEq
using GLMakie
function lorenz(du,u,p,t)
du[1] = p[1]*(u[2]-u[1])
du[2] = u[1]*(p[2]-u[3]) - u[2]
du[3] = u[1]*u[2] - p[3]*u[3]
end
u0 = [1., 5., 10.]
tspan = (0., 100.)
p = (10.0,28.0,8/3)
prob = ODEProblem(lorenz, u0, tspan,p)
sol = solve(prob, Tsit5())
f, a, p = plot(sol)
axislegend(a)
# This is not working!
scale!(p, 10, 1)
f
Ah! I think this is another issue uncovered - the API I used to do this is still pretty new!
You can of course scale the plots individually, by inspecting e.g. ax.scene.plots
, but this seems like an issue which has to be fixed in Makie. The primary thing that has to be solved is that a plot's Transformation should be passed to its children in the event that a plotlist is being generated.
Would you mind filing an issue on the Makie repo, @henry2004y?
Sure! Hopefully there will be a quick fix. Thanks for the new recipe!
And another maybe related issue is that the new recipe does not work with plotting attributes (e.g. linestyle, linewidth
)? Is this an issue for Makie or the recipe @asinghvi17 ?
Same issue unfortunately :(
Same issue unfortunately :(
Is there a temporary workaround for attributes before it's properly fixed in Makie?
Honestly I am now pretty frustrated about the new SpecAPI introduced in Makie v0.20. The old approaches for creating recipes did not limit it capability in so many ways.
Here is yet another issue with PlotSpec
: it does not work (yet) with lift
:
Do you think it's possible to switch back to the more stable APIs for now and switch to the newer experimental Makie APIs once it becomes mature? @asinghvi17
Another issue related to this recipe but maybe not to Makie itself: following the way idxs
is specified in Plots recipes,
fig, ax, pl = lines(sol, idxs=(1,2,3))
is supposed to plot a 3D figure. However, now in Makie it only shows a 2D figure. If I want a 3D figure, I would need to do
f = Figure()
ax = Axis3(f[1, 1],
aspect = :data,
)
lines!(ax, sol; idxs=(1,2,3))
Checklist
Additional context
I thought I'd update the code in #427 for the latest Makie, and while I was at it made it an extension as well.
This doesn't work fully yet, in that:
plot
, likelinewidth
. Setting that theme externally still works, though.