Plot Solution Module
The plot_solution module provides functions for visualizing solutions.
Available Functions
Main.plot_solution.plot_heatmap — Functionplot_heatmap(mesh::Mesh, solution::Vector{Float64}; colourscheme=:blues, show_colorbar=true, savepath=nothing)Plot an interpolated heatmap over a mesh structure with optional cell boundaries, color scheme, and color bar.
Arguments
- mesh::Mesh: A Mesh struct containing the boundary vertices, elements (polygons), and vertex coordinates.
- solution::Vector{Float64}: A vector containing the solution values (e.g., temperature, potential) for each vertex.
Keyword Arguments
- ptitle: A string specifying the plot title.
- colourscheme: A symbol representing the color scheme to use for the heatmap. Default is :blues, but can be any valid color scheme (e.g., :viridis, :plasma).
- show_colorbar::Bool: A boolean flag that determines whether the color bar is shown. Default is true (color bar shown). Set to false to hide the color bar.
savepath: A string specifying the file path to save the plot. If not provided, the plot will be displayed instead.
Behavior
- The function will plot the heatmap by interpolating the solution values over the mesh.
- It fills each element (polygon/triangle) in the mesh with interpolated colors, using the specified color scheme.
- The x and y axis limits are automatically set based on the mesh vertices.
- If
ptitleis provided it adds the string as the title. Otherwise no title will be displayed. - The color bar can be toggled on or off using the show_colorbar argument.
- If
savepathis provided, the plot will be saved to the specified file path. Otherwise, the plot will be displayed interactively.
# Using the default 'blues' color scheme and showing the color bar
plot_heatmap(mesh, solution)# Using the 'plasma' color scheme and hiding the color bar
plot_heatmap(mesh, solution; colourscheme=:plasma, show_colorbar=false, savepath = "heatmap_plot.png")Main.plot_solution.plot_wireframe — Functionplot_wireframe(mesh::Mesh, heights::Vector{Float64}; azimuth=30, elevation=30, solidcolour=nothing, colourscheme=:viridis, savepath=nothing)Plot a 3D wireframe of a mesh with either a solid color or a color scheme based on vertex heights. Optionally, save the plot to a file.
Arguments
mesh::Mesh: AMeshstruct containing the boundary vertices, elements (polygons), and vertex coordinates.heights::Vector{Float64}: A vector containing the heights (z-coordinates) of each vertex.
Keyword Arguments
- If
ptitleis provided it adds the string as the title. Otherwise no title will be displayed. azimuth::Float64: The azimuth angle (horizontal rotation) for viewing the 3D plot. Default is30.elevation::Float64: The elevation angle (vertical rotation) for viewing the 3D plot. Default is30.solidcolour: A solid color for the wireframe (e.g.,:red,:blue). If provided, it overrides the color scheme.colourscheme: A color scheme symbol (e.g.,:viridis,:plasma) to color the wireframe based on vertex heights. Default is:viridis.savepath: A string specifying the file path to save the plot. If not provided, the plot will be displayed instead.
Behavior
- Creates wireframe.
- Assigns ptitle as plot title.
- If
solidcolouris provided, all wireframe lines will be plotted with this solid color. - If
colourschemeis provided andsolidcolourisnothing, the wireframe will be colored based on vertex heights using the color scheme. - If
savepathis provided, the plot will be saved to the specified file path. Otherwise, the plot will be displayed interactively.
# Using a color scheme and saving the plot
plot_wireframe(mesh, heights, ptitle = azimuth=45, elevation=60, colourscheme=:plasma, savepath="mesh_plot.png")# Using a solid color and displaying the plot
plot_wireframe(mesh, heights, azimuth=45, elevation=60, solidcolour=:green)