Update plotting support for Makie for 2D#3057
Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3057 +/- ##
==========================================
+ Coverage 96.83% 96.84% +0.01%
==========================================
Files 636 636
Lines 49581 49643 +62
==========================================
+ Hits 48011 48074 +63
+ Misses 1570 1569 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| interactive surface plots. Heatmap plots are supported for all 2D mesh types | ||
| ([`TreeMesh`](@ref), [`P4estMesh`](@ref), [`UnstructuredMesh2D`](@ref), [`StructuredMesh`](@ref), [`T8codeMesh`](@ref), DGMulti meshes); | ||
| interactive surface plots are available for [`UnstructuredMesh2D`](@ref) and compatible mesh types. |
There was a problem hiding this comment.
Do we need to list everything here? What does "compatible mesh types" mean?
There was a problem hiding this comment.
With "compatible mesh types" I wanted to refer to all mesh types that support iplot. While writing 3f91bd0 I noticed that iplot was actually failing for DGMulti solver due to a missing PlotData2DTriangulated constructor dispatch for DGMulti. I fixed this by adding
PlotData2DTriangulated(u, mesh, equations, dg::DGMulti{2}, cache;
kwargs...) = PlotData2D(u, mesh, equations, dg, cache; kwargs...)to src/visualization/types.jl. This works because PlotData2D for DGMulti returns a PlotData2DTriangulated internally.
|
Thanks a lot! Please ping me when this is ready for a full review. |
|
@ranocha , the PR is ready for review |
ranocha
left a comment
There was a problem hiding this comment.
Thanks a lot, very nice work! I have a couple of comments/questions.
| both for heatmap-type plots (similar to the [Plots.jl](@ref Plots.jl) recipes) as well as for | ||
| interactive surface plots. Support is currently limited to the [`UnstructuredMesh2D`](@ref) type. | ||
| for 1D line plots and 2D heatmap-type plots (similar to the [Plots.jl](@ref Plots.jl) recipes), as well as | ||
| interactive surface plots via `iplot` for all supported 2D mesh types. |
There was a problem hiding this comment.
| interactive surface plots via `iplot` for all supported 2D mesh types. | |
| interactive surface plots via [`iplot`](@ref) for all supported 2D mesh types. |
| With mesh lines overlaid: | ||
| ```@example makie-1d | ||
| plot(pd["scalar"]) | ||
| plot!(Trixi.getmesh(pd)) | ||
| ``` |
There was a problem hiding this comment.
Since we allow plot_mesh = true for oter plot types, we should do so for 1D plots as well, shouldn't we? Could you please update the code such that the following extended example works as well? Note that getmesh is exported by Trixi.jl, so we do not need to prepend it by Trixi..
| With mesh lines overlaid: | |
| ```@example makie-1d | |
| plot(pd["scalar"]) | |
| plot!(Trixi.getmesh(pd)) | |
| ``` | |
| With mesh lines overlaid: | |
| ```@example makie-1d | |
| plot(pd["scalar"]) | |
| plot!(getmesh(pd)) | |
| ``` | |
| Alternatively, you can also pass the keyword argument `plot_mesh = true`: | |
| ```@example makie-1d | |
| plot(pd["scalar"], plot_mesh = true) | |
| ``` |
| With mesh overlay: | ||
| ```@example makie-2d | ||
| plot(pd, plot_mesh = true) | ||
| ``` |
There was a problem hiding this comment.
| With mesh overlay: | |
| ```@example makie-2d | |
| plot(pd, plot_mesh = true) | |
| ``` | |
| With mesh overlay: | |
| ```@example makie-2d | |
| plot(pd, plot_mesh = true) | |
| ``` | |
| Note that `plot!(getmesh(pd))` only plots the mesh in the currently active axis, e.g., | |
| ```@example makie-2d | |
| plot(pd) | |
| plot!(getmesh(pd)) | |
| ``` |
| plot(pd, plot_mesh = true) | ||
| ``` | ||
|
|
||
| A key advantage of Makie over Plots.jl is the ability to compose plots on a custom axis, |
There was a problem hiding this comment.
| A key advantage of Makie over Plots.jl is the ability to compose plots on a custom axis, | |
| A key advantage of Makie.jl over Plots.jl is the ability to compose plots on a custom axis, |
| aspect = DataAspect()) | ||
| plt = plot!(ax, pd["rho"], colormap = :berlin) | ||
| Colorbar(fig[1, 2], colormap = :berlin) | ||
| plot!(Trixi.getmesh(pd)) |
There was a problem hiding this comment.
| plot!(Trixi.getmesh(pd)) | |
| plot!(getmesh(pd)) |
|
|
||
| # single-variable plot with axis and colorbar (works for all PlotData2DTriangulated meshes) | ||
| pd = PlotData2D(sol) | ||
| fap = Makie.plot(pd["rho"]) |
There was a problem hiding this comment.
| fap = Makie.plot(pd["rho"]) | |
| fap = @trixi_test_nowarn Makie.plot(pd["rho"]) |
| @trixi_test_nowarn Makie.plot(pd["rho"], plot_mesh = true) | ||
|
|
||
| # explicit PlotMesh overlay (works for all PlotData2DTriangulated meshes) | ||
| Makie.plot(pd["rho"]) |
There was a problem hiding this comment.
| Makie.plot(pd["rho"]) | |
| @trixi_test_nowarn Makie.plot(pd["rho"]) |
| # explicit PlotMesh overlay (works for all PlotData2DTriangulated meshes) | ||
| Makie.plot(pd["rho"]) | ||
| @trixi_test_nowarn Makie.plot!(Trixi.PlotMesh(pd)) | ||
| Makie.plot(pd["rho"]) |
There was a problem hiding this comment.
| Makie.plot(pd["rho"]) | |
| @trixi_test_nowarn Makie.plot(pd["rho"]) |
|
|
||
| # explicit PlotMesh overlay (works for all PlotData2DTriangulated meshes) | ||
| Makie.plot(pd["rho"]) | ||
| @trixi_test_nowarn Makie.plot!(Trixi.PlotMesh(pd)) |
There was a problem hiding this comment.
| @trixi_test_nowarn Makie.plot!(Trixi.PlotMesh(pd)) | |
| @trixi_test_nowarn Makie.plot!(getmesh(pd)) |
| Makie.plot(pd["rho"]) | ||
| @trixi_test_nowarn Makie.plot!(Trixi.PlotMesh(pd)) | ||
| Makie.plot(pd["rho"]) | ||
| @trixi_test_nowarn Makie.plot!(Trixi.PlotMesh(pd), color = :black, |
There was a problem hiding this comment.
| @trixi_test_nowarn Makie.plot!(Trixi.PlotMesh(pd), color = :black, | |
| @trixi_test_nowarn Makie.plot!(getmesh(pd), color = :black, |
…Trixi.jl into plotting_support_for_Makie_2d
…Trixi.jl into plotting_support_for_Makie_2d
Extension of #3035 to add
Makie.plotsupport for 2D, addressing #1872.Changes
Makie.plot(sol)andMakie.plot(pd)now work for all 2D mesh typesMakie.plot(pd["rho"])Makie.plot(pd, plot_mesh = true)orMakie.plot!(Trixi.getmesh(pd))Makie.plot!(ax, pd["rho"])plot_meshkwarginTrixiHeatmaprecipe was ignoredplot_mesh(wasshow_meshin some functions before)Example