Public API
Visualizer
GridVisualize.GridVisualizer — Typestruct GridVisualizerGridVisualizer struct
GridVisualize.GridVisualizer — MethodGridVisualizer(; Plotter, kwargs...) -> GridVisualizer
Create a grid visualizer
Plotter: defaults to default_plotter() and can be PyPlot, Plots, VTKView, Makie or `PlutoVista´. This pattern allows to pass the backend as a module to a plot function without heavy default package dependencies.
Depending on the layout keyword argument, a 2D grid of subplots is created. Further ...plot! commands then plot into one of these subplots:
vis=GridVisualizer(Plotter=PyPlot, layout=(2,2)
...plot!(vis[1,2], ...)A ...plot command just implicitly creates a plot context:
gridplot(grid, Plotter=PyPlot) is equivalent to
vis=GridVisualizer(Plotter=PyPlot, layout=(1,1))
gridplot!(vis,grid)
reveal(vis)Please note that the return values of all plot commands are specific to the Plotter.
An interactive mode switch key for GLMakie (,) and VTKView (*) allows to toggle between "gallery view" showing all plots at once and "focused view" showing only one plot.
Keyword arguments: see available_kwargs
GridVisualize.SubVisualizer — TypeA SubVisualizer is just a dictionary which contains plotting information, including the type of the plotter and its position in the plot.
GridVisualize.reveal — Functionreveal(visualizer::GridVisualizer) -> Any
Finish and show plot. Same as setting :reveal=true or :show=true in last plot statement for a context.
GridVisualize.save — Functionsave(fname::String, visualizer::GridVisualizer) -> Any
Save last plotted figure from visualizer to disk.
save(fname::String, scene; Plotter) -> Any
Save scene returned from reveal, scalarplot or gridplot to disk.
Plotters
GridVisualize.default_plotter — Functiondefault_plotter()Return default plotter backend. By default, this is set to one of PlutoVista,GLMakie,PyPlot and Plots if one of these packages is imported.
GridVisualize.default_plotter! — Functiondefault_plotter!(Module)Set plotter module or nothing as the default plotter backend.
GridVisualize.plottertype — Functionplottertype(Plotter)
Heuristically detect type of plotter, returns the corresponding abstract type for plotting.
plottertype(p)
Return the type of a plotter.
GridVisualize.PyPlotType — Typeabstract type PyPlotType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
GridVisualize.MakieType — Typeabstract type MakieType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
GridVisualize.PlotsType — Typeabstract type PlotsType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
GridVisualize.PlutoVistaType — Typeabstract type PlutoVistaType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
GridVisualize.VTKViewType — Typeabstract type VTKViewType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter. Experimental.
GridVisualize.MeshCatType — Typeabstract type MeshCatType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter. Experimental.
Plotting grids
GridVisualize.gridplot — Functiongridplot(grid::ExtendableGrid; Plotter, kwargs...) -> Any
Create grid visualizer and plot grid
Keyword arguments: see available_kwargs
gridplot(X::AbstractVector; kwargs...) -> Any
gridplot(
X::AbstractVector,
Y::AbstractVector;
kwargs...
) -> Any
gridplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector;
kwargs...
) -> Any
gridplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix;
kwargs...
) -> Any
GridVisualize.gridplot! — Functiongridplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid;
kwargs...
)
Plot grid into subplot in the visualizer. If [i,j] is omitted, [1,1] is assumed.
Keyword arguments: see available_kwargs
gridplot!(
p::GridVisualizer,
grid::ExtendableGrid;
kwargs...
) -> Any
gridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
X::AbstractVector;
kwargs...
) -> Any
gridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
X::AbstractVector,
Y::AbstractVector;
kwargs...
) -> Any
gridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector;
kwargs...
) -> Any
gridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
kwargs...
) -> Any
Plotting scalar data
GridVisualize.scalarplot — Functionscalarplot(
grid::ExtendableGrid,
func;
Plotter,
kwargs...
) -> Any
Plot node vector on grid as P1 FEM function on the triangulation.
If instead of the node vector, a function is given, it will be evaluated on the grid.
If instead of the grid, vectors for coordinates are given, a grid is created automatically.
For keyword arguments, see available_kwargs
scalarplot(func::AbstractVector; kwargs...) -> Any
scalarplot(
X::AbstractArray{T<:Number, 1},
func;
kwargs...
) -> Any
scalarplot(
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
scalarplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
scalarplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
GridVisualize.scalarplot! — Functionscalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func;
kwargs...
)
Plot node vector on grid as P1 FEM function on the triangulation into subplot in the visualizer. If [i,j] is omitted, [1,1] is assumed.
If instead of the node vector, a function is given, it will be evaluated on the grid.
If instead of the grid, coordinate vectors are given, a temporary grid is created.
Keyword arguments: see available_kwargs
scalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grids::Array{ExtendableGrid{Tv, Ti}, 1},
parentgrid::ExtendableGrid{Tv, Ti},
funcs::AbstractVector;
kwargs...
) -> Any
Plot node vectors on subgrids of parent grid as P1 FEM function on the triangulation into subplot in the visualizer. If [i,j] is omitted, [1,1] is assumed. Keyword arguments: see available_kwargs
scalarplot!(
p::GridVisualizer,
grid::ExtendableGrid,
func;
kwargs...
) -> Any
scalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func::Function;
kwargs...
)
scalarplot!(
p::GridVisualizer,
grids::Array{ExtendableGrid{Tv, Ti}, 1},
parentgrid::ExtendableGrid{Tv, Ti},
funcs::AbstractVector;
kwargs...
) -> Any
scalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
func::AbstractVector;
kwargs...
) -> Any
scalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
X::AbstractVector,
func;
kwargs...
) -> Any
scalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
scalarplot!(
ctx::GridVisualizer,
X::AbstractVector,
func;
kwargs...
) -> Any
scalarplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
scalarplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
scalarplot!(
ctx::GridVisualizer,
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
Plotting vector data
GridVisualize.vectorplot — Functionvectorplot(
grid::ExtendableGrid,
func;
Plotter,
kwargs...
) -> Any
Plot piecewise linear vector field as quiver plot.
vectorplot(
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
vectorplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
vectorplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
GridVisualize.vectorplot! — Functionvectorplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func;
kwargs...
)
Plot piecewise linear vector field as quiver plot.
vectorplot!(
p::GridVisualizer,
grid::ExtendableGrid,
func;
kwargs...
) -> Any
vectorplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
vectorplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
vectorplot!(
ctx::GridVisualizer,
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
GridVisualize.streamplot — Functionstreamplot(
grid::ExtendableGrid,
func;
Plotter,
kwargs...
) -> Any
Plot piecewise linear vector field as stream plot. (2D pyplot only)
streamplot(
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
streamplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
streamplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
GridVisualize.streamplot! — Functionstreamplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func;
kwargs...
)
Plot piecewise linear vector field as stream plot. (2D pyplot only)
streamplot!(
p::GridVisualizer,
grid::ExtendableGrid,
func;
kwargs...
) -> Any
streamplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
streamplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
streamplot!(
ctx::GridVisualizer,
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
Custom plots
GridVisualize.customplot — Functioncustomplot(func; Plotter, kwargs...) -> Any
Custom user plot.
GridVisualize.customplot! — Functioncustomplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
func;
kwargs...
)
customplot!(
func,
ctx::Union{Nothing, Dict{Symbol, Any}};
kwargs...
)
Variant for do block syntax.
customplot!(p::GridVisualizer, func; kwargs...)
customplot!(func, p::GridVisualizer; kwargs...)
Variant for do block syntax.
Plotting TriangulateIO
GridVisualize.plot_triangulateio — Functionplot_triangulateio(;Plotter,
triangulateio;
voronoi=nothing,
circumcircles = false,
kwargs...)Plot TriangulateIO struct exported by Triangulate.jl.
GridVisualize.plot_triangulateio! — Functionplot_triangulateio!(
ctx::Union{Nothing, Dict{Symbol, Any}},
triangulateio;
kwargs...
) -> Any
plot_triangulateio!(
p::GridVisualizer,
triangulateio;
kwargs...
) -> Any
Keyword Arguments
GridVisualize.available_kwargs — Functionavailable_kwargs()
Available kwargs for all methods of this package.
show: Show plot immediately. Default:falsereveal: Show plot immediately (same as :show). Default:falseclear: Clear plot before adding new content. Default:truelayout: Layout of plots in window. Default:(1, 1)size: Plot window resolution. Default:(500, 500)legend: Legend (position): one of [:none, :best, :lt, :ct, :rt, :lc, :rc, :lb, :cb, :rb]. Default:nonetitle: Plot title. Default: ``xlabel: x axis label. Default:xylabel: y axis label. Default:yzlabel: z axis label. Default:zxlimits: x axis limits. Default:(1, -1)ylimits: y axis limits. Default:(1, -1)zlimits: z axis limits. Default:(1, -1)limits: function limits. Default:(1, -1)xscale: x axis scale: one of [:log, :identity]. Default:identityyscale: y axis scale: one of [:log, :identity]. Default:identityaspect: XY Aspect ratio modification. Default:1.0fontsize: Fontsize of titles. All others are relative to it. Default:20linewidth: linewidth for isolines or 1D plots. Default:2linestyle: 1D Plot linestyle: one of [:solid, :dash, :dot, :dashdot, :dashdotdot]. Default:solidmarkevery: 1D plot marker stride. Default:5markersize: 1D plot marker size. Default:5markershape: 1D plot marker shape: one of [:none, :circle, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :+, :x]. Default:nonecolor: 1D plot line color. Default:RGB{Float64}(0.0, 0.0, 0.0)cellwise: 1D plots cellwise; unmaintained and can be slow). Default:falselabel: 1D plot label. Default: ``levels: array of isolevels or number of isolevels for contour plots. Default:7elevation: 2D plot height factor for elevation. Default:0.0colorlevels: 2D/3D contour plot: number of color levels. Default:51colormap: 2D/3D contour plot color map (any from ColorSchemes.jl). Default:viridiscolorbar: 2D/3D plot colorbar. One of [:none, :vertical, :horizontal]. Default:verticalcolorbarticks: number of ticks in colorbar (:default sets it equal to levels). Default:defaultoutlinealpha: 3D outline surface alpha value. Default:0.05levelalpha: 3D isolevel alpha. Default:0.25planealpha: 3D plane section alpha. Default:0.25tetxplane_tol: tolerance for tet-plane intersection in 3D. Default:0.0rasterpoints: Number of quiver points resp. half number of streamplot interpolation points in the maximum extent direction. . Default:16offset: Offset of quiver grid. Default:defaultvscale: Vector field scale for quiver grid. Default:1.0vconstant: Set all arrow length constant in vector plot. Default:falsevnormalize: Normalize vector field before scaling. Default:trueinterior: 3D plot interior of grid. Default:truexplanes: 3D x plane positions or number thereof. Default:[1.7976931348623157e308]yplanes: 3D y plane positions or number thereof. Default:[1.7976931348623157e308]zplanes: 3D z plane positions or number thereof. Default:[1.7976931348623157e308]zoom: Zoom level. Default:1.0gridscale: Grid scale factor. Will be applied also to planes, spacing. Default:1cellcoloring: Coloring of cells: one of [:cellregions, :pcolors, :partitions]. Default:cellregionsazim: 3D azimuth angle (in degrees). Default:-60elev: 3D elevation angle (in degrees). Default:30perspectiveness: 3D perspective A number between 0 and 1, where 0 is orthographic, and 1 full perspective. Default:0.25scene3d: 3D plot type of Makie scene. Alternative to:Axis3is:LScene. Default:Axis3viewmode: Axis3d viewmode for Makie plots. Possible values :fit or :free. Default:fitfignumber: Figure number (PyPlot). Default:1framepos: Subplot position in frame (VTKView). Default:1subplot: Private: Actual subplot. Default:(1, 1)backend: Backend for PlutoVista plot. Default:defaultdim: Data dimension for PlutoVista plot. Default:1regions: List of regions to plot. Default:allspecies: Number of species to plot or number of species in regions. Default:1spacing: Removed from API. Default:nothingshow_colorbar: Show color bar next to plots. Default:trueslice: Plot a dim-1 slice along a hyperplane expression :(αx ± βy [± γz] ± δ)) or a fixed axis pair, e.g., :x => 3. Default:nothing
Supporting methods
GridVisualize.vectorsample — Function vectorsample(grid::ExtendableGrid{Tv, Ti}, v;
offset = :default,
rasterpoints = 15,
reltol = 1.0e-10,
gridscale = 1.0,
xlimits = (1, -1),
ylimits = (1, -1),
zlimits = (1, -1)) where {Tv, Ti}Extract values of given vector field (either nodal values of a piecewise linear vector field or a callback function providing evaluation of the vector field for given generalized barycentric coordinates). at all sampling points on offset+ i*spacing for i in Z^d defined by the tuples offset and spacing. Returned values can be fed into quiverdata
By default, offset is at the minimum of grid coordinates, and spacing is defined the largest grid extend divided by 10.
The intermediate rasterflux in future versions can be used to calculate streamlines.
The code is 3D ready.
GridVisualize.quiverdata — Function function quiverdata(rastercoord,
rasterflux;
vscale = 1.0,
vnormalize = true,
vconstant = false)Extract nonzero fluxes for quiver plots from rastergrid obtained by vectorsample.
Returns qc, qv - d x nquiver matrices.
If vnormalize is true, the vector field is normalized to vscale*min(spacing), otherwise, it is scaled by vscale Result data are meant to be ready for being passed to calls to quiver with various plotting backends.
Creating movies
GridVisualize.movie — Functionmovie( func, vis::GridVisualizer; file = nothing, format = "gif", kwargs... )Record a movie with GLMakie backend. MP4 files and gifs can be created.