Plotting companion module for ExtendableGrids.jl Provides grid and scalar piecewise linear function plotting for various plotting backends on simplicial grids in one, two or three space dimensions. The main supported backends are PyPlot, GLMakie and PlutoVista.
The code is rather new and quite a few codepaths are untested. Please be prepared to help fixing things.
Plotting a grid, a function or a vector field
gridplot(grid, Plotter=PyPlot) scalarplot(grid, function,Plotter=PyPlot) vectorplot(grid, vectorfunction,Plotter=PyPlot) streamplot(grid, vectorfunction,Plotter=PyPlot)
This works for 1/2/3D grids and either a function represented by its values on the nodes of the grid, or a scalar function of 1, 2 or 3 variables, respectively. Vector plots are currenly available for 2D only, and stream plots only for PyPlot.
Plot appearance can be tweaked by a number of keyword arguments.
Plotters can be e.g. Plots, PyPlot, GLMakie, PlutoVista - we pass the module exported by the package. Different plotters can be used at the same time.
Multiple plots in one plotting window
vis=GridVisualizer(Plotter=GLMakie, layout=(1,2)) gridplot!(vis[1,1],grid) scalarplot!(vis[1,2],grid,function) reveal(vis)
This using fast updating via observables for GLMakie and persistent divs with PlutoVista.
vis=GridVisualizer(Plotter=GLMakie) for i=1:N function=calculate(i) scalarplot!(vis,grid,function) reveal(vis) end
Currently, these can be recorded with GLMakie, CairoMakie and Plots backends both from the REPL and Pluto notebooks. MP4 files and gifs can be created. PyPlot possibly will follow.
This shows the animated graphic in the REPL (essentially the same as above) and creates an embedded video in a Pluto notebook:
vis=GridVisualizer(Plotter=Plots) movie(vis) do vis for i=1:N function=calculate(i) scalarplot!(vis,grid,function) reveal(vis) end end
To save to a file instead of showing in a notebooks or from the REPL , use:
vis=GridVisualizer(Plotter=CairoMakie) movie(vis, file="video.mp4") do vis for i=1:N function=calculate(i) scalarplot!(vis,grid,function) reveal(vis) end end
Setting a default plotter
Instead of specifying a
Plotter in calls to
scalarplot, a default plotter can be set:
default_plotter!(PyPlot) gridplot(grid) scalarplot(grid, function)
default_plotter!(GLMakie) vis=GridVisualizer(layout=(1,2)) gridplot!(vis[1,1],grid) scalarplot!(vis[1,2],grid,function)
Switching off plotting
Plotter=nothing in the respective places, or set
and all plotting functions will do nothing.
Available plotting backends and functionality.
- 'y': available
- 'i': some level of interactive control
- '(y)': availability only on rectangular grids
- 'p': planned (no schedule though)
- 'n': probably not, also in the future
Plotting into the plot pane of Visual Studio Code is working. Here, you can use WGLMakie as backend. This works only with the mutating functions, i.e. you should use something like
Plotting in Pluto notebooks for PyPlot, Plots, GLMakie is working.
Chances are that things work with Jupyter as well. Please ping me if you would like to volunteer with testing and possibly fixing this.