Plot Cross Section#
- pybamm.plot_3d_cross_section(solution: Solution, variable: str, t: float | None, plane: str = 'yz', position: float = 0.5, n_pts: int = 100, ax=None, show_plot: bool = True, cmap: str = 'inferno', levels: int = 20, use_offset: bool = False, show_mesh: bool = False, mesh_color: str = 'white', mesh_alpha: float = 0.4, mesh_linewidth: float = 0.7, mesh_tolerance: float | None = None, **kwargs)[source]#
Plots a high-quality 2D cross-section of a 3D variable from a PyBaMM solution, with mesh overlay support.
- Parameters:
solution (pybamm.Solution) – The solution object containing the 3D variable.
variable (str, optional) – The name of the 3D variable to plot (default: “Cell temperature [K]”).
t (float, optional) – The time at which to plot. If None, the last timestep is used.
plane (str, optional) – The plane for the cross-section (‘xy’, ‘yz’, ‘xz’, ‘rz’).
position (float, optional) – The relative position (0 to 1) along the third axis to take the slice.
n_pts (int, optional) – The number of points for the plotting grid in each direction.
ax (matplotlib.axes.Axes, optional) – The axes on which to draw the plot. If None, a new figure is created.
show_plot (bool, optional) – Whether to display the plot.
cmap (str, optional) – The colormap for the plot.
levels (int, optional) – The number of contour levels for the plot.
use_offset (bool, optional) – Parameter to control color bar format to use scientific notation (default: False).
show_mesh (bool, optional) – Whether to overlay the calculated FEM mesh slice on the plot.
mesh_color (str, optional) – Color of the mesh lines.
mesh_alpha (float, optional) – Transparency of the mesh lines.
mesh_linewidth (float, optional) – Width of the mesh lines.
**kwargs – Additional keyword arguments passed to matplotlib.contourf.