-
-
Notifications
You must be signed in to change notification settings - Fork 110
Fix Makie recipe to support 3D plots with automatic LScene detection #1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This commit adds `preferred_axis_type` methods for AbstractTimeseriesSolution, DEIntegrator, and AbstractEnsembleSolution that automatically detect when 3D plotting is requested (idxs=(1,2,3)) and return LScene as the preferred axis type instead of the default Axis. This fixes issue #947 where 3D plots failed because Makie defaulted to 2D Axis instead of using LScene for 3D visualizations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
# Define preferred axis type based on the idxs parameter | ||
function Makie.preferred_axis_type(plot::Plot{<:Tuple{<:SciMLBase.AbstractTimeseriesSolution}}) | ||
if haskey(plot, :idxs) || haskey(plot, :vars) | ||
idxs = haskey(plot, :idxs) ? plot[:idxs][] : (haskey(plot, :vars) ? plot[:vars][] : nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
idxs = haskey(plot, :idxs) ? plot[:idxs][] : (haskey(plot, :vars) ? plot[:vars][] : nothing) | |
idxs = haskey(plot, :idxs) ? plot[:idxs][] : | |
(haskey(plot, :vars) ? plot[:vars][] : nothing) |
if idxs isa Tuple && length(idxs) == 3 | ||
return Makie.LScene | ||
elseif idxs isa AbstractArray && length(idxs) == 3 | ||
return Makie.LScene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
return Makie.LScene | |
return Makie.LScene |
# Define preferred axis type for integrator plots | ||
function Makie.preferred_axis_type(plot::Plot{<:Tuple{<:SciMLBase.DEIntegrator}}) | ||
if haskey(plot, :idxs) || haskey(plot, :vars) | ||
idxs = haskey(plot, :idxs) ? plot[:idxs][] : (haskey(plot, :vars) ? plot[:vars][] : nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
idxs = haskey(plot, :idxs) ? plot[:idxs][] : (haskey(plot, :vars) ? plot[:vars][] : nothing) | |
idxs = haskey(plot, :idxs) ? plot[:idxs][] : | |
(haskey(plot, :vars) ? plot[:vars][] : nothing) |
if idxs isa Tuple && length(idxs) == 3 | ||
return Makie.LScene | ||
elseif idxs isa AbstractArray && length(idxs) == 3 | ||
return Makie.LScene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
return Makie.LScene | |
return Makie.LScene |
# Define preferred axis type for ensemble plots | ||
function Makie.preferred_axis_type(plot::Plot{<:Tuple{<:SciMLBase.AbstractEnsembleSolution}}) | ||
if haskey(plot, :idxs) || haskey(plot, :vars) | ||
idxs = haskey(plot, :idxs) ? plot[:idxs][] : (haskey(plot, :vars) ? plot[:vars][] : nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
idxs = haskey(plot, :idxs) ? plot[:idxs][] : (haskey(plot, :vars) ? plot[:vars][] : nothing) | |
idxs = haskey(plot, :idxs) ? plot[:idxs][] : | |
(haskey(plot, :vars) ? plot[:vars][] : nothing) |
if idxs isa Tuple && length(idxs) == 3 | ||
return Makie.LScene | ||
elseif idxs isa AbstractArray && length(idxs) == 3 | ||
return Makie.LScene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
return Makie.LScene | |
return Makie.LScene |
@asinghvi17 can you look at this one? |
@@ -23,6 +23,19 @@ function ensure_plottrait(PT::Type, arg, desired_plottrait_type::Type) | |||
end | |||
end | |||
|
|||
# Define preferred axis type based on the idxs parameter | |||
function Makie.preferred_axis_type(plot::Plot{<:Tuple{<:SciMLBase.AbstractTimeseriesSolution}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dispatch doesn't actually do anything. I don't think you can actually hook into this in this way in Makie v0.24. It might need a small patch, I'm PRing that to Makie now
Summary
preferred_axis_type
methods for SciML solution typesThe Problem
When plotting a 3D system using the Makie recipe with
idxs = (1, 2, 3)
, the plot fails because Makie defaults to a 2DAxis
instead of usingLScene
for 3D visualizations. Users had to manually specifyaxis = (; type = LScene)
as a workaround.The Solution
Added
preferred_axis_type
methods for:AbstractTimeseriesSolution
DEIntegrator
AbstractEnsembleSolution
These methods check if
idxs
(or the deprecatedvars
) parameter contains exactly 3 indices, and if so, returnMakie.LScene
as the preferred axis type. Otherwise, they default toMakie.Axis
.Test plan
🤖 Generated with Claude Code