Public API

Visualizer

GridVisualize.GridVisualizerMethod
GridVisualizer(; 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 implicitely 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

source
GridVisualize.SubVisualizerType

A SubVisualizer is just a dictionary which contains plotting information, including the type of the plotter and its position in the plot.

source
GridVisualize.revealFunction
reveal(visualizer::GridVisualizer) -> Any

Finish and show plot. Same as setting :reveal=true or :show=true in last plot statment for a context.

source

Plotters

GridVisualize.default_plotterFunction
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.

source
GridVisualize.plottertypeFunction
plottertype(Plotter)

Heuristically detect type of plotter, returns the corresponding abstract type for plotting.

source
plottertype(p)

Return the type of a plotter.

source
GridVisualize.VTKViewTypeType
abstract type VTKViewType <: GridVisualize.AbstractPlotterType

Abstract type for dispatching on plotter. Experimental.

source
GridVisualize.MeshCatTypeType
abstract type MeshCatType <: GridVisualize.AbstractPlotterType

Abstract type for dispatching on plotter. Experimental.

source

Plotting grids

GridVisualize.gridplotFunction
gridplot(grid::ExtendableGrid; Plotter, kwargs...) -> Any

Create grid visualizer and plot grid

Keyword arguments: see available_kwargs

source
gridplot(X::AbstractVector; kwargs...) -> Any
source
gridplot(
    X::AbstractVector,
    Y::AbstractVector;
    kwargs...
) -> Any
source
gridplot(
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector;
    kwargs...
) -> Any
source
gridplot(
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix;
    kwargs...
) -> Any
source
GridVisualize.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

source
gridplot!(
    p::GridVisualizer,
    grid::ExtendableGrid;
    kwargs...
) -> Any
source
gridplot!(
    vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
    X::AbstractVector;
    kwargs...
) -> Any
source
gridplot!(
    vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
    X::AbstractVector,
    Y::AbstractVector;
    kwargs...
) -> Any
source
gridplot!(
    vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector;
    kwargs...
) -> Any
source
gridplot!(
    vis::Union{Nothing, Dict{Symbol, Any}, GridVisualizer},
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    kwargs...
) -> Any
source

Plotting scalar data

GridVisualize.scalarplotFunction
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

source
scalarplot(func::AbstractVector; kwargs...) -> Any
source
scalarplot(
    X::AbstractArray{T<:Number, 1},
    func;
    kwargs...
) -> Any
source
scalarplot(
    X::AbstractVector,
    Y::AbstractVector,
    func;
    kwargs...
) -> Any
source
scalarplot(
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector,
    func;
    kwargs...
) -> Any
source
scalarplot(
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source
GridVisualize.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

source
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

source
scalarplot!(
    p::GridVisualizer,
    grid::ExtendableGrid,
    func;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    grid::ExtendableGrid,
    func::Function;
    kwargs...
)
source
scalarplot!(
    p::GridVisualizer,
    grids::Array{ExtendableGrid{Tv, Ti}, 1},
    parentgrid::ExtendableGrid{Tv, Ti},
    funcs::AbstractVector;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    func::AbstractVector;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    X::AbstractVector,
    func;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    func;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    Y::AbstractVector,
    func;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector,
    func;
    kwargs...
) -> Any
source
scalarplot!(
    ctx::GridVisualizer,
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source

Plotting vector data

GridVisualize.vectorplotFunction
vectorplot(
    grid::ExtendableGrid,
    func;
    Plotter,
    kwargs...
) -> Any

Plot piecewise linear vector field as quiver plot.

source
vectorplot(
    X::AbstractVector,
    Y::AbstractVector,
    func;
    kwargs...
) -> Any
source
vectorplot(
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector,
    func;
    kwargs...
) -> Any
source
vectorplot(
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source
GridVisualize.vectorplot!Function
vectorplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    grid::ExtendableGrid,
    func;
    kwargs...
)

Plot piecewise linear vector field as quiver plot.

source
vectorplot!(
    p::GridVisualizer,
    grid::ExtendableGrid,
    func;
    kwargs...
) -> Any
source
vectorplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    Y::AbstractVector,
    func;
    kwargs...
) -> Any
source
vectorplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector,
    func;
    kwargs...
) -> Any
source
vectorplot!(
    ctx::GridVisualizer,
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source
GridVisualize.streamplotFunction
streamplot(
    grid::ExtendableGrid,
    func;
    Plotter,
    kwargs...
) -> Any

Plot piecewise linear vector field as stream plot. (2D pyplot only)

source
streamplot(
    X::AbstractVector,
    Y::AbstractVector,
    func;
    kwargs...
) -> Any
source
streamplot(
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector,
    func;
    kwargs...
) -> Any
source
streamplot(
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source
GridVisualize.streamplot!Function
streamplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    grid::ExtendableGrid,
    func;
    kwargs...
)

Plot piecewise linear vector field as stream plot. (2D pyplot only)

source
streamplot!(
    p::GridVisualizer,
    grid::ExtendableGrid,
    func;
    kwargs...
) -> Any
source
streamplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    Y::AbstractVector,
    func;
    kwargs...
) -> Any
source
streamplot!(
    ctx::GridVisualizer,
    X::AbstractVector,
    Y::AbstractVector,
    Z::AbstractVector,
    func;
    kwargs...
) -> Any
source
streamplot!(
    ctx::GridVisualizer,
    coord::AbstractMatrix,
    cellnodes::AbstractMatrix,
    func;
    kwargs...
) -> Any
source

Custom plots

GridVisualize.customplot!Function
customplot!(
    ctx::Union{Nothing, Dict{Symbol, Any}},
    func;
    kwargs...
)
source
customplot!(
    func,
    ctx::Union{Nothing, Dict{Symbol, Any}};
    kwargs...
)

Variant for do block syntax.

source
customplot!(p::GridVisualizer, func; kwargs...)
source
customplot!(func, p::GridVisualizer; kwargs...)

Variant for do block syntax.

source

Keyword Arguments

GridVisualize.available_kwargsFunction
available_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 befor 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

source

Supporting methods

GridVisualize.vectorsampleFunction
      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.

source
GridVisualize.quiverdataFunction
 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.

source