GridVisualize
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.
General usage:
gridplot(grid, Plotter=PyPlot)
scalarplot(grid, function,Plotter=PyPlot)
For multiple plots in one plotting window, see the documentation.
Available plotting backends and functionality. 'i' means some level of interactive control. '(y)' means avaliability only on rectangular resp. cuboid grids.
| | PyPlot | *Makie | Plots | VTKView | |–––––-:|––––|––––|–––-|––––-| | scalar, 1D | y | y | y | y | | grid, 1D | y | y | y | n | | scalar, 2D | y | y,i | (y) | y,i | | grid, 2D | y | y,i | (y) | y,i | | scalar, 3D | y | y,i | no | y,i | | grid, 3D | y | y,i | no | y,i |
Currently, the Makie part probably will have some problems.
Documentation
The basic structure is to create a GridVisualizer p
which allows to have a grid of subplots. The visualize!
methods then plot into a subplot p[i,j]
. Creation of a GridVisiualizer takes a Plotter
keyword argument, which allow to specify plotting module. Supported are:
- From the REPL: GLMakie, PyPlot, VTKView (linux only), Plots (no 3D, no unstructured)
- From Pluto notebooks: GLMakie PyPlot, Plots, WGLMakie (experimental), MeshCat (experimental)
Note that functionality here mostly will be added on necessity.
API
GridVisualize.SubVis
— TypeA SubVis is just a dictionary which contains plotting information, including type of the plotter and its position in the plot.
GridVisualize.GridVisualizer
— Typestruct GridVisualizer
Context type for plots.
GridVisualize.GridVisualizer
— MethodGridVisualizer(; Plotter, kwargs...)
Create a plot context.
Plotter: defaults to nothing
and can be PyPlot
, Plots
, VTKView
, Makie
. This pattern to pass the backend as a module to a plot function allows to circumvent to create 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:
p=GridVisualizer(Plotter=PyPlot, layout=(2,2)
...plot!(p[1,2], ...)
````
A `...plot` command just implicitely creates a plot context:
julia ...plot(..., Plotter=PyPlot)
is equivalent to
julia p=GridVisualizer(Plotter=PyPlot, layout=(1,1) ...plot!(p,...) ```
Please note that the return values of all plot commands are specific to the Plotter.
Depending on the backend, interactive mode switch between "gallery view" showing all plots at onece and "focused view" showing only one plot is possible.
Keyword arguments:
outline: Plot outline of domain. Default: true
alpha: Surface alpha value. Default: 0.1
colorbar: Show colorbar in plots. Default: true
subplot: Actual subplot. Default: (1, 1)
zplane: zplane for 3D visualization. Default: 1.7976931348623157e308
colormap: Contour plot colormap (any from ColorSchemes.jl). Default: viridis
label: Label of plot. Default:
cellwise: Cellwise 1D plot, can be slow). Default: false
interior: Plot interior of grid. Default: true
flevel: isolevel for 3D visualization. Default: 1.7976931348623157e308
elev: Elevation angle for 3D visualization (in degrees). Default: 30
azim: Azimuth angle for 3D visualization (in degrees). Default: -60
colorlevels: Number of color levels for contour plot. Default: 51
isolines: Number of isolines in contour plot. Default: 11
fast: Fast updates (with Makie, restricted functionality). Default: true
fignumber: Figure number (PyPlot). Default: 1
title: Plot title. Default:
framepos: Subplot position in frame (VTKView). Default: 1
zlimits: z limits. Default: (1, -1)
flimits: function limits. Default: (1, -1)
yplane: yplane for 3D visualization. Default: 1.7976931348623157e308
aspect: Aspect ratio modification. Default: 1.0
reveal: Show plot immediately (same as :show). Default: false
clear: Clear plot before new plot.. Default: true
legend: Add legend to plot. Default: true
resolution: Plot xy resolution. Default: (500, 500)
elevation: Height factor for elevation of 2D plot. Default: 0.0
layout: Layout of plots. Default: (1, 1)
axisgrid: Show background grid in plots. Default: true
color: Color of lines on plot. Default: (0, 0, 0)
show: Show plot immediately. Default: false
xlimits: x limits. Default: (1, -1)
legend_location: Location of legend. Default: upper right
edges: Plot grid edges when plotting grid. Default: true
xplane: xplane for 3D visualization. Default: 1.7976931348623157e308
ylimits: y limits. Default: (1, -1)
GridVisualize.MakieType
— Typeabstract type MakieType
Abstract type for dispatching on plotter
GridVisualize.MeshCatType
— Typeabstract type MeshCatType
Abstract type for dispatching on plotter
GridVisualize.PlotsType
— Typeabstract type PlotsType
Abstract type for dispatching on plotter
GridVisualize.PyPlotType
— Typeabstract type PyPlotType
Abstract type for dispatching on plotter
GridVisualize.VTKViewType
— Typeabstract type VTKViewType
Abstract type for dispatching on plotter
Base.getindex
— Methodgetindex(p, i, j)
Return a SubVis
Base.size
— Methodsize(p)
Return the layout of a GridVisualizer
GridVisualize.gridplot!
— Methodgridplot!(p, grid; kwargs...)
Plot grid.
Keyword arguments:
outline: Plot outline of domain. Default: true
alpha: Surface alpha value. Default: 0.1
colorbar: Show colorbar in plots. Default: true
subplot: Actual subplot. Default: (1, 1)
zplane: zplane for 3D visualization. Default: 1.7976931348623157e308
colormap: Contour plot colormap (any from ColorSchemes.jl). Default: viridis
label: Label of plot. Default:
cellwise: Cellwise 1D plot, can be slow). Default: false
interior: Plot interior of grid. Default: true
flevel: isolevel for 3D visualization. Default: 1.7976931348623157e308
elev: Elevation angle for 3D visualization (in degrees). Default: 30
azim: Azimuth angle for 3D visualization (in degrees). Default: -60
colorlevels: Number of color levels for contour plot. Default: 51
isolines: Number of isolines in contour plot. Default: 11
fast: Fast updates (with Makie, restricted functionality). Default: true
fignumber: Figure number (PyPlot). Default: 1
title: Plot title. Default:
framepos: Subplot position in frame (VTKView). Default: 1
zlimits: z limits. Default: (1, -1)
flimits: function limits. Default: (1, -1)
yplane: yplane for 3D visualization. Default: 1.7976931348623157e308
aspect: Aspect ratio modification. Default: 1.0
reveal: Show plot immediately (same as :show). Default: false
clear: Clear plot before new plot.. Default: true
legend: Add legend to plot. Default: true
resolution: Plot xy resolution. Default: (500, 500)
elevation: Height factor for elevation of 2D plot. Default: 0.0
layout: Layout of plots. Default: (1, 1)
axisgrid: Show background grid in plots. Default: true
color: Color of lines on plot. Default: (0, 0, 0)
show: Show plot immediately. Default: false
xlimits: x limits. Default: (1, -1)
legend_location: Location of legend. Default: upper right
edges: Plot grid edges when plotting grid. Default: true
xplane: xplane for 3D visualization. Default: 1.7976931348623157e308
ylimits: y limits. Default: (1, -1)
GridVisualize.gridplot!
— Methodgridplot!(ctx, grid; kwargs...)
Plot grid.
Keyword arguments:
outline: Plot outline of domain. Default: true
alpha: Surface alpha value. Default: 0.1
colorbar: Show colorbar in plots. Default: true
subplot: Actual subplot. Default: (1, 1)
zplane: zplane for 3D visualization. Default: 1.7976931348623157e308
colormap: Contour plot colormap (any from ColorSchemes.jl). Default: viridis
label: Label of plot. Default:
cellwise: Cellwise 1D plot, can be slow). Default: false
interior: Plot interior of grid. Default: true
flevel: isolevel for 3D visualization. Default: 1.7976931348623157e308
elev: Elevation angle for 3D visualization (in degrees). Default: 30
azim: Azimuth angle for 3D visualization (in degrees). Default: -60
colorlevels: Number of color levels for contour plot. Default: 51
isolines: Number of isolines in contour plot. Default: 11
fast: Fast updates (with Makie, restricted functionality). Default: true
fignumber: Figure number (PyPlot). Default: 1
title: Plot title. Default:
framepos: Subplot position in frame (VTKView). Default: 1
zlimits: z limits. Default: (1, -1)
flimits: function limits. Default: (1, -1)
yplane: yplane for 3D visualization. Default: 1.7976931348623157e308
aspect: Aspect ratio modification. Default: 1.0
reveal: Show plot immediately (same as :show). Default: false
clear: Clear plot before new plot.. Default: true
legend: Add legend to plot. Default: true
resolution: Plot xy resolution. Default: (500, 500)
elevation: Height factor for elevation of 2D plot. Default: 0.0
layout: Layout of plots. Default: (1, 1)
axisgrid: Show background grid in plots. Default: true
color: Color of lines on plot. Default: (0, 0, 0)
show: Show plot immediately. Default: false
xlimits: x limits. Default: (1, -1)
legend_location: Location of legend. Default: upper right
edges: Plot grid edges when plotting grid. Default: true
xplane: xplane for 3D visualization. Default: 1.7976931348623157e308
ylimits: y limits. Default: (1, -1)
GridVisualize.gridplot
— Methodgridplot(grid; Plotter, kwargs...)
Plot grid without predefined context.
Keyword arguments:
outline: Plot outline of domain. Default: true
alpha: Surface alpha value. Default: 0.1
colorbar: Show colorbar in plots. Default: true
subplot: Actual subplot. Default: (1, 1)
zplane: zplane for 3D visualization. Default: 1.7976931348623157e308
colormap: Contour plot colormap (any from ColorSchemes.jl). Default: viridis
label: Label of plot. Default:
cellwise: Cellwise 1D plot, can be slow). Default: false
interior: Plot interior of grid. Default: true
flevel: isolevel for 3D visualization. Default: 1.7976931348623157e308
elev: Elevation angle for 3D visualization (in degrees). Default: 30
azim: Azimuth angle for 3D visualization (in degrees). Default: -60
colorlevels: Number of color levels for contour plot. Default: 51
isolines: Number of isolines in contour plot. Default: 11
fast: Fast updates (with Makie, restricted functionality). Default: true
fignumber: Figure number (PyPlot). Default: 1
title: Plot title. Default:
framepos: Subplot position in frame (VTKView). Default: 1
zlimits: z limits. Default: (1, -1)
flimits: function limits. Default: (1, -1)
yplane: yplane for 3D visualization. Default: 1.7976931348623157e308
aspect: Aspect ratio modification. Default: 1.0
reveal: Show plot immediately (same as :show). Default: false
clear: Clear plot before new plot.. Default: true
legend: Add legend to plot. Default: true
resolution: Plot xy resolution. Default: (500, 500)
elevation: Height factor for elevation of 2D plot. Default: 0.0
layout: Layout of plots. Default: (1, 1)
axisgrid: Show background grid in plots. Default: true
color: Color of lines on plot. Default: (0, 0, 0)
show: Show plot immediately. Default: false
xlimits: x limits. Default: (1, -1)
legend_location: Location of legend. Default: upper right
edges: Plot grid edges when plotting grid. Default: true
xplane: xplane for 3D visualization. Default: 1.7976931348623157e308
ylimits: y limits. Default: (1, -1)
GridVisualize.ismakie
— Methodismakie(Plotter)
Heuristically check if Plotter is Makie/WGLMakie
GridVisualize.ismeshcat
— Methodismeshcat(Plotter)
Heuristically check if Plotter is MeshCat
GridVisualize.isplots
— Methodisplots(Plotter)
Heuristically check if Plotter is Plots
GridVisualize.ispyplot
— Methodispyplot(Plotter)
Heuristically check if Plotter is PyPlot
GridVisualize.isvtkview
— Methodisvtkview(Plotter)
Heuristically check if Plotter is VTKView
GridVisualize.plottertype
— Methodplottertype(p)
Return the type of a plotter.
GridVisualize.plottertype
— Methodplottertype(Plotter)
Heuristically detect type of plotter, returns the corresponding abstract type fro plotting.
GridVisualize.reveal
— Methodreveal(p)
Finish and show plot. Same as setting :reveal=true
or :show=true
in last scalarplot statment for a context.
GridVisualize.save
— Methodsave(fname, p)
Save figure to disk
GridVisualize.scalarplot!
— Methodscalarplot!(ctx, grid, func; kwargs...)
Plot scalar function on grid as P1 FEM function.
Keyword arguments
outline: Plot outline of domain. Default: true
alpha: Surface alpha value. Default: 0.1
colorbar: Show colorbar in plots. Default: true
subplot: Actual subplot. Default: (1, 1)
zplane: zplane for 3D visualization. Default: 1.7976931348623157e308
colormap: Contour plot colormap (any from ColorSchemes.jl). Default: viridis
label: Label of plot. Default:
cellwise: Cellwise 1D plot, can be slow). Default: false
interior: Plot interior of grid. Default: true
flevel: isolevel for 3D visualization. Default: 1.7976931348623157e308
elev: Elevation angle for 3D visualization (in degrees). Default: 30
azim: Azimuth angle for 3D visualization (in degrees). Default: -60
colorlevels: Number of color levels for contour plot. Default: 51
isolines: Number of isolines in contour plot. Default: 11
fast: Fast updates (with Makie, restricted functionality). Default: true
fignumber: Figure number (PyPlot). Default: 1
title: Plot title. Default:
framepos: Subplot position in frame (VTKView). Default: 1
zlimits: z limits. Default: (1, -1)
flimits: function limits. Default: (1, -1)
yplane: yplane for 3D visualization. Default: 1.7976931348623157e308
aspect: Aspect ratio modification. Default: 1.0
reveal: Show plot immediately (same as :show). Default: false
clear: Clear plot before new plot.. Default: true
legend: Add legend to plot. Default: true
resolution: Plot xy resolution. Default: (500, 500)
elevation: Height factor for elevation of 2D plot. Default: 0.0
layout: Layout of plots. Default: (1, 1)
axisgrid: Show background grid in plots. Default: true
color: Color of lines on plot. Default: (0, 0, 0)
show: Show plot immediately. Default: false
xlimits: x limits. Default: (1, -1)
legend_location: Location of legend. Default: upper right
edges: Plot grid edges when plotting grid. Default: true
xplane: xplane for 3D visualization. Default: 1.7976931348623157e308
ylimits: y limits. Default: (1, -1)
GridVisualize.scalarplot
— Methodscalarplot(grid, func; Plotter, kwargs...)
Plot vector on grid without predefined context as P1 FEM function.
Keyword arguments:
outline: Plot outline of domain. Default: true
alpha: Surface alpha value. Default: 0.1
colorbar: Show colorbar in plots. Default: true
subplot: Actual subplot. Default: (1, 1)
zplane: zplane for 3D visualization. Default: 1.7976931348623157e308
colormap: Contour plot colormap (any from ColorSchemes.jl). Default: viridis
label: Label of plot. Default:
cellwise: Cellwise 1D plot, can be slow). Default: false
interior: Plot interior of grid. Default: true
flevel: isolevel for 3D visualization. Default: 1.7976931348623157e308
elev: Elevation angle for 3D visualization (in degrees). Default: 30
azim: Azimuth angle for 3D visualization (in degrees). Default: -60
colorlevels: Number of color levels for contour plot. Default: 51
isolines: Number of isolines in contour plot. Default: 11
fast: Fast updates (with Makie, restricted functionality). Default: true
fignumber: Figure number (PyPlot). Default: 1
title: Plot title. Default:
framepos: Subplot position in frame (VTKView). Default: 1
zlimits: z limits. Default: (1, -1)
flimits: function limits. Default: (1, -1)
yplane: yplane for 3D visualization. Default: 1.7976931348623157e308
aspect: Aspect ratio modification. Default: 1.0
reveal: Show plot immediately (same as :show). Default: false
clear: Clear plot before new plot.. Default: true
legend: Add legend to plot. Default: true
resolution: Plot xy resolution. Default: (500, 500)
elevation: Height factor for elevation of 2D plot. Default: 0.0
layout: Layout of plots. Default: (1, 1)
axisgrid: Show background grid in plots. Default: true
color: Color of lines on plot. Default: (0, 0, 0)
show: Show plot immediately. Default: false
xlimits: x limits. Default: (1, -1)
legend_location: Location of legend. Default: upper right
edges: Plot grid edges when plotting grid. Default: true
xplane: xplane for 3D visualization. Default: 1.7976931348623157e308
ylimits: y limits. Default: (1, -1)