Plots
GridVisualize and PlutoVista
Visualization of finite element solutions is possible, for example, via Nodal Evaluations and the plotting routines from ExtendableGrids.jl. For interactive Pluto notebooks, it is recommended to use PlutoVista.jl as the backend for high-quality plots.
UnicodePlots
For quick, in-terminal visualization, several UnicodePlots-based plotters are available via the ExtendableFEMBaseUnicodePlotsExt
extension. This extension is loaded automatically when UnicodePlots is available.
ExtendableFEMBase.unicode_gridplot
— Functionfunction unicode_gridplot(
xgrid::ExtendableGrid;
title = "gridplot",
resolution = (40,20),
color = (200,200,200),
bface_color = (255,0,0),
CanvasType = BrailleCanvas,
plot_based = ON_CELLS, # or ON_FACES/ON_EDGES
kwargs...
Render a quick terminal plot of a 2D grid using UnicodePlots, suitable for quick visualization in the terminal.
This function draws the edges and boundary faces of the given ExtendableGrid
using Unicode characters, with customizable resolution, colors, and plotting style. The plot can be based on cells, faces, or edges, and boundary faces are highlighted with a separate color.
Arguments
xgrid
: TheExtendableGrid
to visualize.
Keyword Arguments
title
: Title of the plot (default:"gridplot"
).resolution
: Tuple specifying the number of columns and rows (characters) in the plot (default:(40, 20)
).autoscale
: Whether to automatically adjust the aspect ratio for the grid (default:true
).color
: RGB tuple for the main grid lines (default:(200, 200, 200)
).bface_color
: RGB tuple for boundary face lines (default:(255, 0, 0)
).CanvasType
: UnicodePlots canvas type to use (default:BrailleCanvas
).plot_based
: Plot based onON_CELLS
,ON_FACES
, orON_EDGES
(default:ON_CELLS
).kwargs...
: Additional keyword arguments passed to the canvas or plot.
Returns
- A
UnicodePlots.Plot
object displaying the grid in the terminal.
Notes
- Requires the UnicodePlots extension to be loaded.
Example
using ExtendableFEMBase, ExtendableGrids, UnicodePlots
grid = simplexgrid(LinRange(0, 1, 5), LinRange(0, 1, 5))
unicode_gridplot(grid; title = "My Grid", resolution = (60, 30))
ExtendableFEMBase.unicode_scalarplot
— Functionfunction unicode_scalarplot(
u::FEVectorBlock;
components = 1:get_ncomponents(u),
abs = false,
resolution = (30,30),
colormap = :viridis,
title = u.name,
kwargs...)
Render a quick terminal plot of one or more components of a finite element function using UnicodePlots.
This function visualizes the nodal values of the FE function stored in u
by interpolating onto a coarse uniform mesh and plotting the result using UnicodePlots.jl. In 1D, all selected components are shown in a single line plot; in 2D, each component is shown as a separate heatmap. If abs = true
, the Euclidean norm over all components is plotted instead.
Arguments
u
: TheFEVectorBlock
containing the finite element function to plot.
Keyword Arguments
components
: Indices of the components to plot (default: all components).abs
: Iftrue
, plot the Euclidean norm over all components (default:false
).nrows
: Number of rows in the grid layout for 2D plots (default:1
).resolution
: Tuple specifying the plot resolution (characters) in each direction (default:(30, 30)
).colormap
: Colormap symbol for 2D heatmaps (default::viridis
).title
: Title of the plot (default:u.name
).kwargs...
: Additional keyword arguments passed to the plotting routines.
Returns
- A
UnicodePlots.Plot
object (or a vector of plots for multiple components in 2D).
Notes
- Requires the UnicodePlots extension to be loaded.