Public API
Visualizer
GridVisualize.GridVisualizer
— Typestruct GridVisualizer
GridVisualizer 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.AbstractPlotterType
Abstract type for dispatching on plotter
GridVisualize.MakieType
— Typeabstract type MakieType <: GridVisualize.AbstractPlotterType
Abstract type for dispatching on plotter
GridVisualize.PlotsType
— Typeabstract type PlotsType <: GridVisualize.AbstractPlotterType
Abstract type for dispatching on plotter
GridVisualize.PlutoVistaType
— Typeabstract type PlutoVistaType <: GridVisualize.AbstractPlotterType
Abstract type for dispatching on plotter
GridVisualize.VTKViewType
— Typeabstract type VTKViewType <: GridVisualize.AbstractPlotterType
Abstract type for dispatching on plotter. Experimental.
GridVisualize.MeshCatType
— Typeabstract type MeshCatType <: GridVisualize.AbstractPlotterType
Abstract 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. eyword 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.
Keyword Arguments
GridVisualize.available_kwargs
— Functionavailable_kwargs()
Available kwargs for all methods of this package.
show
: Show plot immediately. Default:false
reveal
: Show plot immediately (same as :show). Default:false
clear
: Clear plot before adding new content. Default:true
layout
: 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:none
title
: Plot title. Default: ``xlabel
: x axis label. Default:x
ylabel
: y axis label. Default:y
zlabel
: z axis label. Default:z
xlimits
: 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:identity
yscale
: y axis scale: one of [:log, :identity]. Default:identity
aspect
: XY Aspect ratio modification. Default:1.0
fontsize
: Fontsize of titles. All others are relative to it. Default:20
linewidth
: linewidth for isolines or 1D plots. Default:2
linestyle
: 1D Plot linestyle: one of [:solid, :dash, :dot, :dashdot, :dashdotdot]. Default:solid
markevery
: 1D plot marker stride. Default:5
markersize
: 1D plot marker size. Default:5
markershape
: 1D plot marker shape: one of [:none, :circle, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :+, :x]. Default:none
color
: 1D plot line color. Default:(0.0, 0.0, 0.0)
cellwise
: 1D plots cellwise; unmaintained and can be slow). Default:false
label
: 1D plot label. Default: ``levels
: array of isolevels or number of isolevels for contour plots. Default:7
elevation
: 2D plot height factor for elevation. Default:0.0
colorlevels
: 2D/3D contour plot: number of color levels. Default:51
colormap
: 2D/3D contour plot color map (any from ColorSchemes.jl). Default:viridis
colorbar
: 2D/3D plot colorbar. One of [:none, :vertical, :horizontal]. Default:vertical
colorbarticks
: number of ticks in colorbar (:default sets it equal to levels). Default:default
outlinealpha
: 3D outline surface alpha value. Default:0.05
levelalpha
: 3D isolevel alpha. Default:0.25
planealpha
: 3D plane section alpha. Default:0.25
tetxplane_tol
: tolerance for tet-plane intersection in 3D. Default:0.0
rasterpoints
: Number of quiver points resp. half number of streamplot interpolation points in the maximum extent direction. . Default:16
offset
: Offset of quiver grid. Default:default
vscale
: Vector field scale for quiver grid. Default:1.0
vconstant
: Set all arrow length constant in vector plot. Default:false
vnormalize
: Normalize vector field before scaling. Default:true
interior
: 3D plot interior of grid. Default:true
xplanes
: 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.0
gridscale
: Grid scale factor. Will be applied also to planes, spacing. Default:1
cellcoloring
: Coloring of cells: one of [:cellregions, :pcolors, :partitions]. Default:cellregions
azim
: 3D azimuth angle (in degrees). Default:-60
elev
: 3D elevation angle (in degrees). Default:30
perspectiveness
: 3D perspective A number between 0 and 1, where 0 is orthographic, and 1 full perspective. Default:0.25
scene3d
: 3D plot type of Makie scene. Alternaitve to:Axis3
is:LScene
. Default:Axis3
fignumber
: Figure number (PyPlot). Default:1
framepos
: Subplot position in frame (VTKView). Default:1
subplot
: Private: Actual subplot. Default:(1, 1)
backend
: Backend for PlutoVista plot. Default:default
dim
: Data dimension for PlutoVista plot. Default:1
regions
: List of regions to plot. Default:all
species
: Number of species to plot or number of species in regions. Default:1
spacing
: Removed from API. 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.