Public API
Visualizer
GridVisualize.GridVisualizer — Type
GridVisualize.GridVisualizer — Method
GridVisualizer(; Plotter, kwargs...) -> GridVisualizer
Create a grid visualizer
Plotter: defaults to default_plotter() and can be PyPlot, PythonPlot, 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 — Type
A SubVisualizer is just a dictionary which contains plotting information, including the type of the plotter and its position in the plot.
sourceGridVisualize.reveal — Function
reveal(visualizer::GridVisualizer) -> Any
Finish and show plot. Same as setting :reveal=true or :show=true in last plot statement for a context.
GridVisualize.save — Function
save(fname::String, visualizer::GridVisualizer) -> Any
Save last plotted figure from visualizer to disk.
sourcesave(fname::String, scene; Plotter) -> Any
Save scene returned from reveal, scalarplot or gridplot to disk.
Plotters
GridVisualize.default_plotter — Function
default_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! — Function
GridVisualize.plottertype — Function
plottertype(Plotter)
Heuristically detect type of plotter, returns the corresponding abstract type for plotting.
sourceGridVisualize.PythonPlotType — Type
abstract type PythonPlotType <: GridVisualize.AbstractPythonPlotterTypeAbstract type for dispatching on plotter
sourceGridVisualize.PyPlotType — Type
abstract type PyPlotType <: GridVisualize.AbstractPythonPlotterTypeAbstract type for dispatching on plotter
sourceGridVisualize.MakieType — Type
abstract type MakieType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
sourceGridVisualize.PlotsType — Type
abstract type PlotsType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
sourceGridVisualize.PlutoVistaType — Type
abstract type PlutoVistaType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter
sourceGridVisualize.VTKViewType — Type
abstract type VTKViewType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter. Experimental.
sourceGridVisualize.MeshCatType — Type
abstract type MeshCatType <: GridVisualize.AbstractPlotterTypeAbstract type for dispatching on plotter. Experimental.
sourcePlotting grids
GridVisualize.gridplot — Function
gridplot(grid::ExtendableGrid; Plotter, kwargs...) -> Any
Create grid visualizer and plot grid
Keyword arguments: see available_kwargs
gridplot(X::AbstractVector; kwargs...) -> Any
sourcegridplot(
X::AbstractVector,
Y::AbstractVector;
kwargs...
) -> Any
sourcegridplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector;
kwargs...
) -> Any
sourcegridplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix;
kwargs...
) -> Any
sourceGridVisualize.gridplot! — Function
gridplot!(
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
sourcegridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
X::AbstractVector;
kwargs...
) -> Any
sourcegridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
X::AbstractVector,
Y::AbstractVector;
kwargs...
) -> Any
sourcegridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector;
kwargs...
) -> Any
sourcegridplot!(
vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
kwargs...
) -> Any
sourcePlotting scalar data
GridVisualize.scalarplot — Function
scalarplot(
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
sourcescalarplot(
X::AbstractArray{T<:Number, 1},
func;
kwargs...
) -> Any
sourcescalarplot(
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
sourcescalarplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
sourcescalarplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourceGridVisualize.scalarplot! — Function
scalarplot!(
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
sourcescalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func::Function;
kwargs...
)
sourcescalarplot!(
p::GridVisualizer,
grids::Array{ExtendableGrid{Tv, Ti}, 1},
parentgrid::ExtendableGrid{Tv, Ti},
funcs::AbstractVector;
kwargs...
) -> Any
sourcescalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
func::AbstractVector;
kwargs...
) -> Any
sourcescalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
X::AbstractVector,
func;
kwargs...
) -> Any
sourcescalarplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourcescalarplot!(
ctx::GridVisualizer,
X::AbstractVector,
func;
kwargs...
) -> Any
sourcescalarplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
sourcescalarplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
sourcescalarplot!(
ctx::GridVisualizer,
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourcePlotting vector data
GridVisualize.vectorplot — Function
vectorplot(
grid::ExtendableGrid,
func;
Plotter,
kwargs...
) -> Any
Plot piecewise linear vector field as quiver plot.
sourcevectorplot(
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
sourcevectorplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
sourcevectorplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourceGridVisualize.vectorplot! — Function
vectorplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func;
kwargs...
)
Plot piecewise linear vector field as quiver plot.
sourcevectorplot!(
p::GridVisualizer,
grid::ExtendableGrid,
func;
kwargs...
) -> Any
sourcevectorplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
sourcevectorplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
sourcevectorplot!(
ctx::GridVisualizer,
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourceGridVisualize.streamplot — Function
streamplot(
grid::ExtendableGrid,
func;
Plotter,
kwargs...
) -> Any
Plot piecewise linear vector field as stream plot. (2D pyplot only)
sourcestreamplot(
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
sourcestreamplot(
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
sourcestreamplot(
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourceGridVisualize.streamplot! — Function
streamplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
grid::ExtendableGrid,
func;
kwargs...
)
Plot piecewise linear vector field as stream plot. (2D pyplot only)
sourcestreamplot!(
p::GridVisualizer,
grid::ExtendableGrid,
func;
kwargs...
) -> Any
sourcestreamplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
func;
kwargs...
) -> Any
sourcestreamplot!(
ctx::GridVisualizer,
X::AbstractVector,
Y::AbstractVector,
Z::AbstractVector,
func;
kwargs...
) -> Any
sourcestreamplot!(
ctx::GridVisualizer,
coord::AbstractMatrix,
cellnodes::AbstractMatrix,
func;
kwargs...
) -> Any
sourceCustom plots
GridVisualize.customplot — Function
GridVisualize.customplot! — Function
customplot!(
ctx::Union{Nothing, Dict{Symbol, Any}},
func;
kwargs...
)
sourcecustomplot!(
func,
ctx::Union{Nothing, Dict{Symbol, Any}};
kwargs...
) -> Any
Variant for do block syntax.
sourcecustomplot!(p::GridVisualizer, func; kwargs...) -> Any
sourcePlotting TriangulateIO
GridVisualize.plot_triangulateio — Function
plot_triangulateio(;Plotter,
triangulateio;
voronoi=nothing,
circumcircles = false,
kwargs...)Plot TriangulateIO struct exported by Triangulate.jl.
sourceGridVisualize.plot_triangulateio! — Function
plot_triangulateio!(
ctx::Union{Nothing, Dict{Symbol, Any}},
triangulateio;
kwargs...
) -> Any
sourceplot_triangulateio!(
p::GridVisualizer,
triangulateio;
kwargs...
) -> Any
sourceKeyword Arguments
GridVisualize.available_kwargs — Function
available_kwargs()
Available kwargs for all methods of this package.
azim: 3D azimuth angle (in degrees). Default:-60aspect: XY Aspect ratio modification. Default:1.0backend: Backend for PlutoVista plot. Default:defaultcellcoloring: Coloring of cells: one of [:cellregions, :pcolors, :partitions]. Default:cellregionscellwise: 1D plots cellwise; unmaintained and can be slow). Default:falseclear: Clear plot before adding new content. Default:truecolor: 1D plot line color. Default:RGB{Float64}(0.0, 0.0, 0.0)colorbar: 2D/3D plot colorbar. One of [:none, :vertical, :horizontal]. Default:verticalcolorbarticks: number of ticks in colorbar (:default sets it equal to levels). Default:defaultcolorlevels: 2D/3D contour plot: number of color levels. Default:51colormap: 2D/3D contour plot color map (any from ColorSchemes.jl). Default:viridisdim: Data dimension for PlutoVista plot. Default:1elev: 3D elevation angle (in degrees). Default:30elevation: 2D plot height factor for elevation. Default:0.0fignumber: Figure number (PyPlot). Default:1fontsize: Fontsize of titles. All others are relative to it. Default:20framepos: Subplot position in frame (VTKView). Default:1gridscale: Grid scale factor. Will be applied also to planes, spacing. Default:1interior: 3D plot interior of grid. Default:truelabel: 1D plot label. Default: ``layout: Layout of plots in window. Default:(1, 1)levelalpha: 3D isolevel alpha. Default:0.25levels: array of isolevels or number of isolevels for contour plots. Default:7legend: Legend (position): one of [:none, :best, :lt, :ct, :rt, :lc, :rc, :lb, :cb, :rb]. Default:nonelimits: function limits. Default:(1, -1)linestyle: 1D Plot linestyle: one of [:solid, :dash, :dot, :dashdot, :dashdotdot]. Default:solidlinewidth: linewidth for isolines or 1D plots. Default:2markershape: 1D plot marker shape: one of [:none, :circle, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :+, :x]. Default:nonemarkersize: 1D plot marker size. Default:5markevery: 1D plot marker stride. Default:5offset: Offset of quiver grid. Default:defaultoutlinealpha: 3D outline surface alpha value. Default:0.05perspectiveness: 3D perspective A number between 0 and 1, where 0 is orthographic, and 1 full perspective. Default:0.25planealpha: 3D plane section alpha. Default:0.25reveal: Show plot immediately (same as :show). Default:falseregions: List of regions to plot. Default:allrasterpoints: Number of quiver points resp. half number of streamplot interpolation points in the maximum extent direction.. Default:16scene3d: 3D plot type of Makie scene. Alternative to:Axis3is:LScene. Default:Axis3show: Show plot immediately. Default:falseshow_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:nothingsize: Plot window resolution. Default:(500, 500)spacing: Removed from API. Default:nothingspecies: Number of species to plot or number of species in regions. Default:1subplot: Private: Actual subplot. Default:(1, 1)title: Plot title. Default: ``tetxplane_tol: tolerance for tet-plane intersection in 3D. Default:0.0vconstant: Set all arrow length constant in vector plot. Default:falsevnormalize: Normalize vector field before scaling. Default:truevscale: Vector field scale for quiver grid. Default:1.0viewmode: Axis3d viewmode for Makie plots. Possible values :fit or :free. Default:fitxlimits: x axis limits. Default:(1, -1)xplanes: 3D x plane positions or number thereof. Default:[1.7976931348623157e308]xlabel: x axis label. Default:xxscale: x axis scale: one of [:log, :identity]. Default:identityylimits: y axis limits. Default:(1, -1)ylabel: y axis label. Default:yyplanes: 3D y plane positions or number thereof. Default:[1.7976931348623157e308]yscale: y axis scale: one of [:log, :identity]. Default:identityzlimits: z axis limits. Default:(1, -1)zplanes: 3D z plane positions or number thereof. Default:[1.7976931348623157e308]zlabel: z axis label. Default:zzoom: Zoom level. Default:1.0
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.
sourceGridVisualize.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 — Function
movie( func, vis::GridVisualizer; file = nothing, format = "gif", kwargs... )Record a movie with GLMakie backend. MP4 files and gifs can be created.
source