Install Matplotlib with:
pip install pybamm[plot]Quick plotting with sim.plot()
After solving, call sim.plot() to open an interactive slider plot of the default output variables:
pybamm.QuickPlot and calls dynamic_plot(), which renders a matplotlib figure with a time slider.
Choosing variables to plot
QuickPlot
pybamm.QuickPlot gives you full control over the plot configuration. It accepts solutions or simulation objects.
Constructor options
Comparing multiple solutions
Pass a list of solutions or simulations to overlay them:Dynamic (interactive) plot
Calldynamic_plot() directly for the interactive slider:
Static plot at a fixed time
Useplot(t) to render the figure at a single time point (in the solution’s time unit):
Voltage components
pybamm.plot_voltage_components breaks down the terminal voltage into its contributing overpotentials:
Solution object:
Simulation object too:
Summary variables
For multi-cycle experiments,pybamm.plot_summary_variables plots cycle-level degradation metrics:
Capacity [A.h]Loss of lithium inventory [%]Total capacity lost to side reactions [A.h]Loss of active material in negative electrode [%]Loss of active material in positive electrode [%]- Stoichiometric limits
x_100,x_0,y_100,y_0
2D plots
For spatially-resolved models (dimensionality > 0), usepybamm.plot2D to visualise a variable as a function of two spatial coordinates:
x, y, and z arguments must be pybamm.Array objects. plot2D calls matplotlib.pyplot.contourf under the hood.
Creating a GIF
Generate an animated GIF of the solution evolving over time:QuickPlot object:
Working with Matplotlib directly
You can access the underlying Matplotlib figure and axes from aQuickPlot: