Tip

An interactive online version of this notebook is available, which can be accessed via

Alternatively, you may download this notebook and run it offline.

# Tutorial 3 - Basic plotting#

In Tutorial 2, we made use of PyBaMM’s automatic plotting function when comparing models. This gave a good quick overview of many of the key variables in the model. However, by passing in just a few arguments it is easy to plot any of the many other variables that may be of interest to you. We start by building and solving a model as before:

```
[1]:
```

```
%pip install "pybamm[plot,cite]" -q # install PyBaMM if it is not installed
import pybamm
import matplotlib.pyplot as plt
model_dfn = pybamm.lithium_ion.DFN()
sim_dfn = pybamm.Simulation(model_dfn)
sim_dfn.solve([0, 3600])
```

```
Note: you may need to restart the kernel to use updated packages.
```

```
[1]:
```

```
<pybamm.solvers.solution.Solution at 0x139a534f0>
```

We now want to plot a selection of the model variables. To see a full list of the available variables just type:

```
[2]:
```

```
model_dfn.variable_names()
```

```
[2]:
```

```
['Time [s]',
'Time [min]',
'Time [h]',
'x [m]',
'x_n [m]',
'x_s [m]',
'x_p [m]',
'r_n [m]',
'r_p [m]',
'Current variable [A]',
'Total current density [A.m-2]',
'Current [A]',
'C-rate',
'Discharge capacity [A.h]',
'Discharge energy [W.h]',
'Throughput energy [W.h]',
'Throughput capacity [A.h]',
'Porosity',
'Negative electrode porosity',
'X-averaged negative electrode porosity',
'Separator porosity',
'X-averaged separator porosity',
'Positive electrode porosity',
'X-averaged positive electrode porosity',
'Porosity change',
'Negative electrode porosity change [s-1]',
'X-averaged negative electrode porosity change [s-1]',
'Separator porosity change [s-1]',
'X-averaged separator porosity change [s-1]',
'Positive electrode porosity change [s-1]',
'X-averaged positive electrode porosity change [s-1]',
'Negative electrode interface utilisation variable',
'X-averaged negative electrode interface utilisation variable',
'Negative electrode interface utilisation',
'X-averaged negative electrode interface utilisation',
'Positive electrode interface utilisation variable',
'X-averaged positive electrode interface utilisation variable',
'Positive electrode interface utilisation',
'X-averaged positive electrode interface utilisation',
'Negative particle crack length [m]',
'X-averaged negative particle crack length [m]',
'Negative particle cracking rate [m.s-1]',
'X-averaged negative particle cracking rate [m.s-1]',
'Positive particle crack length [m]',
'X-averaged positive particle crack length [m]',
'Positive particle cracking rate [m.s-1]',
'X-averaged positive particle cracking rate [m.s-1]',
'Negative electrode active material volume fraction',
'X-averaged negative electrode active material volume fraction',
'Negative electrode capacity [A.h]',
'Negative particle radius',
'Negative particle radius [m]',
'X-averaged negative particle radius [m]',
'Negative electrode surface area to volume ratio [m-1]',
'X-averaged negative electrode surface area to volume ratio [m-1]',
'Negative electrode active material volume fraction change [s-1]',
'X-averaged negative electrode active material volume fraction change [s-1]',
'Loss of lithium due to loss of active material in negative electrode [mol]',
'Positive electrode active material volume fraction',
'X-averaged positive electrode active material volume fraction',
'Positive electrode capacity [A.h]',
'Positive particle radius',
'Positive particle radius [m]',
'X-averaged positive particle radius [m]',
'Positive electrode surface area to volume ratio [m-1]',
'X-averaged positive electrode surface area to volume ratio [m-1]',
'Positive electrode active material volume fraction change [s-1]',
'X-averaged positive electrode active material volume fraction change [s-1]',
'Loss of lithium due to loss of active material in positive electrode [mol]',
'Separator pressure [Pa]',
'X-averaged separator pressure [Pa]',
'negative electrode transverse volume-averaged velocity [m.s-1]',
'X-averaged negative electrode transverse volume-averaged velocity [m.s-1]',
'separator transverse volume-averaged velocity [m.s-1]',
'X-averaged separator transverse volume-averaged velocity [m.s-1]',
'positive electrode transverse volume-averaged velocity [m.s-1]',
'X-averaged positive electrode transverse volume-averaged velocity [m.s-1]',
'Transverse volume-averaged velocity [m.s-1]',
'negative electrode transverse volume-averaged acceleration [m.s-2]',
'X-averaged negative electrode transverse volume-averaged acceleration [m.s-2]',
'separator transverse volume-averaged acceleration [m.s-2]',
'X-averaged separator transverse volume-averaged acceleration [m.s-2]',
'positive electrode transverse volume-averaged acceleration [m.s-2]',
'X-averaged positive electrode transverse volume-averaged acceleration [m.s-2]',
'Transverse volume-averaged acceleration [m.s-2]',
'Negative electrode volume-averaged velocity [m.s-1]',
'Negative electrode volume-averaged acceleration [m.s-2]',
'X-averaged negative electrode volume-averaged acceleration [m.s-2]',
'Negative electrode pressure [Pa]',
'X-averaged negative electrode pressure [Pa]',
'Positive electrode volume-averaged velocity [m.s-1]',
'Positive electrode volume-averaged acceleration [m.s-2]',
'X-averaged positive electrode volume-averaged acceleration [m.s-2]',
'Positive electrode pressure [Pa]',
'X-averaged positive electrode pressure [Pa]',
'Negative particle stoichiometry',
'Negative particle concentration',
'Negative particle concentration [mol.m-3]',
'X-averaged negative particle concentration',
'X-averaged negative particle concentration [mol.m-3]',
'R-averaged negative particle concentration',
'R-averaged negative particle concentration [mol.m-3]',
'Average negative particle concentration',
'Average negative particle concentration [mol.m-3]',
'Negative particle surface stoichiometry',
'Negative particle surface concentration',
'Negative particle surface concentration [mol.m-3]',
'X-averaged negative particle surface concentration',
'X-averaged negative particle surface concentration [mol.m-3]',
'Negative electrode extent of lithiation',
'X-averaged negative electrode extent of lithiation',
'Minimum negative particle concentration',
'Maximum negative particle concentration',
'Minimum negative particle concentration [mol.m-3]',
'Maximum negative particle concentration [mol.m-3]',
'Minimum negative particle surface concentration',
'Maximum negative particle surface concentration',
'Minimum negative particle surface concentration [mol.m-3]',
'Maximum negative particle surface concentration [mol.m-3]',
'Positive particle stoichiometry',
'Positive particle concentration',
'Positive particle concentration [mol.m-3]',
'X-averaged positive particle concentration',
'X-averaged positive particle concentration [mol.m-3]',
'R-averaged positive particle concentration',
'R-averaged positive particle concentration [mol.m-3]',
'Average positive particle concentration',
'Average positive particle concentration [mol.m-3]',
'Positive particle surface stoichiometry',
'Positive particle surface concentration',
'Positive particle surface concentration [mol.m-3]',
'X-averaged positive particle surface concentration',
'X-averaged positive particle surface concentration [mol.m-3]',
'Positive electrode extent of lithiation',
'X-averaged positive electrode extent of lithiation',
'Minimum positive particle concentration',
'Maximum positive particle concentration',
'Minimum positive particle concentration [mol.m-3]',
'Maximum positive particle concentration [mol.m-3]',
'Minimum positive particle surface concentration',
'Maximum positive particle surface concentration',
'Minimum positive particle surface concentration [mol.m-3]',
'Maximum positive particle surface concentration [mol.m-3]',
'Negative electrode potential [V]',
'X-averaged negative electrode potential [V]',
'Negative electrode ohmic losses [V]',
'X-averaged negative electrode ohmic losses [V]',
'Gradient of negative electrode potential [V.m-1]',
'Positive electrode potential [V]',
'X-averaged positive electrode potential [V]',
'Positive electrode ohmic losses [V]',
'X-averaged positive electrode ohmic losses [V]',
'Gradient of positive electrode potential [V.m-1]',
'Porosity times concentration [mol.m-3]',
'Negative electrode porosity times concentration [mol.m-3]',
'Separator porosity times concentration [mol.m-3]',
'Positive electrode porosity times concentration [mol.m-3]',
'Total lithium in electrolyte [mol]',
'Electrolyte potential [V]',
'X-averaged electrolyte potential [V]',
'X-averaged electrolyte overpotential [V]',
'Gradient of electrolyte potential [V.m-1]',
'Negative electrolyte potential [V]',
'X-averaged negative electrolyte potential [V]',
'Gradient of negative electrolyte potential [V.m-1]',
'Separator electrolyte potential [V]',
'X-averaged separator electrolyte potential [V]',
'Gradient of separator electrolyte potential [V.m-1]',
'Positive electrolyte potential [V]',
'X-averaged positive electrolyte potential [V]',
'Gradient of positive electrolyte potential [V.m-1]',
'Ambient temperature [K]',
'Cell temperature [K]',
'Negative current collector temperature [K]',
'Positive current collector temperature [K]',
'X-averaged cell temperature [K]',
'Volume-averaged cell temperature [K]',
'Negative electrode temperature [K]',
'X-averaged negative electrode temperature [K]',
'Separator temperature [K]',
'X-averaged separator temperature [K]',
'Positive electrode temperature [K]',
'X-averaged positive electrode temperature [K]',
'Ambient temperature [C]',
'Cell temperature [C]',
'Negative current collector temperature [C]',
'Positive current collector temperature [C]',
'X-averaged cell temperature [C]',
'Volume-averaged cell temperature [C]',
'Negative electrode temperature [C]',
'X-averaged negative electrode temperature [C]',
'Separator temperature [C]',
'X-averaged separator temperature [C]',
'Positive electrode temperature [C]',
'X-averaged positive electrode temperature [C]',
'Negative current collector potential [V]',
'Inner SEI thickness [m]',
'Outer SEI thickness [m]',
'X-averaged inner SEI thickness [m]',
'X-averaged outer SEI thickness [m]',
'SEI [m]',
'Total SEI thickness [m]',
'X-averaged SEI thickness [m]',
'X-averaged total SEI thickness [m]',
'X-averaged negative electrode resistance [Ohm.m2]',
'Inner SEI interfacial current density [A.m-2]',
'X-averaged inner SEI interfacial current density [A.m-2]',
'Outer SEI interfacial current density [A.m-2]',
'X-averaged outer SEI interfacial current density [A.m-2]',
'SEI interfacial current density [A.m-2]',
'X-averaged SEI interfacial current density [A.m-2]',
'Inner SEI on cracks thickness [m]',
'Outer SEI on cracks thickness [m]',
'X-averaged inner SEI on cracks thickness [m]',
'X-averaged outer SEI on cracks thickness [m]',
'SEI on cracks [m]',
'Total SEI on cracks thickness [m]',
'X-averaged SEI on cracks thickness [m]',
'X-averaged total SEI on cracks thickness [m]',
'Inner SEI on cracks interfacial current density [A.m-2]',
'X-averaged inner SEI on cracks interfacial current density [A.m-2]',
'Outer SEI on cracks interfacial current density [A.m-2]',
'X-averaged outer SEI on cracks interfacial current density [A.m-2]',
'SEI on cracks interfacial current density [A.m-2]',
'X-averaged SEI on cracks interfacial current density [A.m-2]',
'Lithium plating concentration [mol.m-3]',
'X-averaged lithium plating concentration [mol.m-3]',
'Dead lithium concentration [mol.m-3]',
'X-averaged dead lithium concentration [mol.m-3]',
'Lithium plating thickness [m]',
'X-averaged lithium plating thickness [m]',
'Dead lithium thickness [m]',
'X-averaged dead lithium thickness [m]',
'Loss of lithium to lithium plating [mol]',
'Loss of capacity to lithium plating [A.h]',
'Negative electrode lithium plating reaction overpotential [V]',
'X-averaged negative electrode lithium plating reaction overpotential [V]',
'Lithium plating interfacial current density [A.m-2]',
'X-averaged lithium plating interfacial current density [A.m-2]',
'Negative crack surface to volume ratio [m-1]',
'Negative electrode roughness ratio',
'X-averaged negative electrode roughness ratio',
'Positive crack surface to volume ratio [m-1]',
'Positive electrode roughness ratio',
'X-averaged positive electrode roughness ratio',
'Electrolyte transport efficiency',
'Negative electrolyte transport efficiency',
'X-averaged negative electrolyte transport efficiency',
'Separator electrolyte transport efficiency',
'X-averaged separator electrolyte transport efficiency',
'Positive electrolyte transport efficiency',
'X-averaged positive electrolyte transport efficiency',
'Electrode transport efficiency',
'Negative electrode transport efficiency',
'X-averaged negative electrode transport efficiency',
'Separator electrode transport efficiency',
'X-averaged separator electrode transport efficiency',
'Positive electrode transport efficiency',
'X-averaged positive electrode transport efficiency',
'Separator volume-averaged velocity [m.s-1]',
'Separator volume-averaged acceleration [m.s-2]',
'X-averaged separator volume-averaged acceleration [m.s-2]',
'Volume-averaged velocity [m.s-1]',
'Volume-averaged acceleration [m.s-1]',
'X-averaged volume-averaged acceleration [m.s-1]',
'Pressure [Pa]',
'Negative electrode open-circuit potential [V]',
'X-averaged negative electrode open-circuit potential [V]',
'Negative electrode entropic change [V.K-1]',
'X-averaged negative electrode entropic change [V.K-1]',
'Positive electrode open-circuit potential [V]',
'X-averaged positive electrode open-circuit potential [V]',
'Positive electrode entropic change [V.K-1]',
'X-averaged positive electrode entropic change [V.K-1]',
'Negative electrode effective conductivity',
'Negative electrode current density [A.m-2]',
'Positive electrode effective conductivity',
'Positive electrode current density [A.m-2]',
'Electrode current density [A.m-2]',
'Positive current collector potential [V]',
'Local voltage [V]',
'Voltage [V]',
'Contact overpotential [V]',
'Electrolyte concentration concatenation [mol.m-3]',
'Negative electrolyte concentration [mol.m-3]',
'X-averaged negative electrolyte concentration [mol.m-3]',
'Separator electrolyte concentration [mol.m-3]',
'X-averaged separator electrolyte concentration [mol.m-3]',
'Positive electrolyte concentration [mol.m-3]',
'X-averaged positive electrolyte concentration [mol.m-3]',
'Negative electrolyte concentration',
'Negative electrolyte concentration [Molar]',
'X-averaged negative electrolyte concentration',
'X-averaged negative electrolyte concentration [Molar]',
'Separator electrolyte concentration',
'Separator electrolyte concentration [Molar]',
'X-averaged separator electrolyte concentration',
'X-averaged separator electrolyte concentration [Molar]',
'Positive electrolyte concentration',
'Positive electrolyte concentration [Molar]',
'X-averaged positive electrolyte concentration',
'X-averaged positive electrolyte concentration [Molar]',
'Electrolyte concentration [mol.m-3]',
'X-averaged electrolyte concentration [mol.m-3]',
'Electrolyte concentration',
'Electrolyte concentration [Molar]',
'X-averaged electrolyte concentration',
'X-averaged electrolyte concentration [Molar]',
'Electrolyte current density [A.m-2]',
'X-averaged concentration overpotential [V]',
'X-averaged electrolyte ohmic losses [V]',
'Negative electrode surface potential difference [V]',
'X-averaged negative electrode surface potential difference [V]',
'Positive electrode surface potential difference [V]',
'X-averaged positive electrode surface potential difference [V]',
'Ohmic heating [W.m-3]',
'X-averaged Ohmic heating [W.m-3]',
'Volume-averaged Ohmic heating [W.m-3]',
'Irreversible electrochemical heating [W.m-3]',
'X-averaged irreversible electrochemical heating [W.m-3]',
'Volume-averaged irreversible electrochemical heating [W.m-3]',
'Reversible heating [W.m-3]',
'X-averaged reversible heating [W.m-3]',
'Volume-averaged reversible heating [W.m-3]',
'Total heating [W.m-3]',
'X-averaged total heating [W.m-3]',
'Volume-averaged total heating [W.m-3]',
'Current collector current density [A.m-2]',
'Inner SEI concentration [mol.m-3]',
'X-averaged inner SEI concentration [mol.m-3]',
'Outer SEI concentration [mol.m-3]',
'X-averaged outer SEI concentration [mol.m-3]',
'SEI concentration [mol.m-3]',
'X-averaged SEI concentration [mol.m-3]',
'Loss of lithium to SEI [mol]',
'Loss of capacity to SEI [A.h]',
'X-averaged negative electrode SEI interfacial current density [A.m-2]',
'Negative electrode SEI interfacial current density [A.m-2]',
'Positive electrode SEI interfacial current density [A.m-2]',
'X-averaged positive electrode SEI volumetric interfacial current density [A.m-2]',
'Positive electrode SEI volumetric interfacial current density [A.m-3]',
'Negative electrode SEI volumetric interfacial current density [A.m-3]',
'X-averaged negative electrode SEI volumetric interfacial current density [A.m-3]',
'Inner SEI on cracks concentration [mol.m-3]',
'X-averaged inner SEI on cracks concentration [mol.m-3]',
'Outer SEI on cracks concentration [mol.m-3]',
'X-averaged outer SEI on cracks concentration [mol.m-3]',
'SEI on cracks concentration [mol.m-3]',
'X-averaged SEI on cracks concentration [mol.m-3]',
'Loss of lithium to SEI on cracks [mol]',
'Loss of capacity to SEI on cracks [A.h]',
'X-averaged negative electrode SEI on cracks interfacial current density [A.m-2]',
'Negative electrode SEI on cracks interfacial current density [A.m-2]',
'Positive electrode SEI on cracks interfacial current density [A.m-2]',
'X-averaged positive electrode SEI on cracks volumetric interfacial current density [A.m-2]',
'Positive electrode SEI on cracks volumetric interfacial current density [A.m-3]',
'Negative electrode SEI on cracks volumetric interfacial current density [A.m-3]',
'X-averaged negative electrode SEI on cracks volumetric interfacial current density [A.m-3]',
'Negative electrode lithium plating interfacial current density [A.m-2]',
'X-averaged negative electrode lithium plating interfacial current density [A.m-2]',
'Lithium plating volumetric interfacial current density [A.m-3]',
'X-averaged lithium plating volumetric interfacial current density [A.m-3]',
'X-averaged positive electrode lithium plating interfacial current density [A.m-2]',
'X-averaged positive electrode lithium plating volumetric interfacial current density [A.m-3]',
'Positive electrode lithium plating interfacial current density [A.m-2]',
'Positive electrode lithium plating volumetric interfacial current density [A.m-3]',
'Negative electrode lithium plating volumetric interfacial current density [A.m-3]',
'X-averaged negative electrode lithium plating volumetric interfacial current density [A.m-3]',
'Negative electrode interfacial current density [A.m-2]',
'X-averaged negative electrode interfacial current density [A.m-2]',
'X-averaged negative electrode total interfacial current density [A.m-2]',
'X-averaged negative electrode total volumetric interfacial current density [A.m-3]',
'Negative electrode exchange current density [A.m-2]',
'X-averaged negative electrode exchange current density [A.m-2]',
'Negative electrode reaction overpotential [V]',
'X-averaged negative electrode reaction overpotential [V]',
'Negative electrode volumetric interfacial current density [A.m-3]',
'X-averaged negative electrode volumetric interfacial current density [A.m-3]',
'SEI film overpotential [V]',
'X-averaged SEI film overpotential [V]',
'Positive electrode interfacial current density [A.m-2]',
'X-averaged positive electrode interfacial current density [A.m-2]',
'X-averaged positive electrode total interfacial current density [A.m-2]',
'X-averaged positive electrode total volumetric interfacial current density [A.m-3]',
'Positive electrode exchange current density [A.m-2]',
'X-averaged positive electrode exchange current density [A.m-2]',
'Positive electrode reaction overpotential [V]',
'X-averaged positive electrode reaction overpotential [V]',
'Positive electrode volumetric interfacial current density [A.m-3]',
'X-averaged positive electrode volumetric interfacial current density [A.m-3]',
'Negative particle rhs [mol.m-3.s-1]',
'Negative particle bc [mol.m-2]',
'Negative particle effective diffusivity [m2.s-1]',
'X-averaged negative particle effective diffusivity [m2.s-1]',
'Negative particle flux [mol.m-2.s-1]',
'Negative electrode stoichiometry',
'Negative electrode volume-averaged concentration',
'Negative electrode volume-averaged concentration [mol.m-3]',
'Total lithium in primary phase in negative electrode [mol]',
'Positive particle rhs [mol.m-3.s-1]',
'Positive particle bc [mol.m-2]',
'Positive particle effective diffusivity [m2.s-1]',
'X-averaged positive particle effective diffusivity [m2.s-1]',
'Positive particle flux [mol.m-2.s-1]',
'Positive electrode stoichiometry',
'Positive electrode volume-averaged concentration',
'Positive electrode volume-averaged concentration [mol.m-3]',
'Total lithium in primary phase in positive electrode [mol]',
'Electrolyte flux [mol.m-2.s-1]',
'Electrolyte diffusion flux [mol.m-2.s-1]',
'Electrolyte migration flux [mol.m-2.s-1]',
'Electrolyte convection flux [mol.m-2.s-1]',
'Sum of negative electrode electrolyte reaction source terms [A.m-3]',
'Sum of x-averaged negative electrode electrolyte reaction source terms [A.m-3]',
'Sum of negative electrode volumetric interfacial current densities [A.m-3]',
'Sum of x-averaged negative electrode volumetric interfacial current densities [A.m-3]',
'Sum of positive electrode electrolyte reaction source terms [A.m-3]',
'Sum of x-averaged positive electrode electrolyte reaction source terms [A.m-3]',
'Sum of positive electrode volumetric interfacial current densities [A.m-3]',
'Sum of x-averaged positive electrode volumetric interfacial current densities [A.m-3]',
'Interfacial current density [A.m-2]',
'Exchange current density [A.m-2]',
'Sum of volumetric interfacial current densities [A.m-3]',
'Sum of electrolyte reaction source terms [A.m-3]',
'X-averaged open-circuit voltage [V]',
'Measured open-circuit voltage [V]',
'X-averaged reaction overpotential [V]',
'X-averaged solid phase ohmic losses [V]',
'X-averaged battery open-circuit voltage [V]',
'Measured battery open-circuit voltage [V]',
'X-averaged battery reaction overpotential [V]',
'X-averaged battery solid phase ohmic losses [V]',
'X-averaged battery electrolyte ohmic losses [V]',
'X-averaged battery concentration overpotential [V]',
'Battery voltage [V]',
'Change in measured open-circuit voltage [V]',
'Local ECM resistance [Ohm]',
'Terminal power [W]',
'Power [W]',
'Resistance [Ohm]',
'Total lithium in negative electrode [mol]',
'LAM_ne [%]',
'Loss of active material in negative electrode [%]',
'Total lithium in positive electrode [mol]',
'LAM_pe [%]',
'Loss of active material in positive electrode [%]',
'LLI [%]',
'Loss of lithium inventory [%]',
'Loss of lithium inventory, including electrolyte [%]',
'Total lithium [mol]',
'Total lithium in particles [mol]',
'Total lithium capacity [A.h]',
'Total lithium capacity in particles [A.h]',
'Total lithium lost [mol]',
'Total lithium lost from particles [mol]',
'Total lithium lost from electrolyte [mol]',
'Total lithium lost to side reactions [mol]',
'Total capacity lost to side reactions [A.h]']
```

There are a *lot* of variables. You can also search the list of variables for a particular string (e.g. “electrolyte”)

```
[3]:
```

```
model_dfn.variables.search("electrolyte")
```

```
Electrolyte concentration
Electrolyte concentration [Molar]
Electrolyte concentration [mol.m-3]
Electrolyte concentration concatenation [mol.m-3]
Electrolyte convection flux [mol.m-2.s-1]
Electrolyte current density [A.m-2]
Electrolyte diffusion flux [mol.m-2.s-1]
Electrolyte flux [mol.m-2.s-1]
Electrolyte migration flux [mol.m-2.s-1]
Electrolyte potential [V]
Electrolyte transport efficiency
Gradient of electrolyte potential [V.m-1]
Gradient of negative electrolyte potential [V.m-1]
Gradient of positive electrolyte potential [V.m-1]
Gradient of separator electrolyte potential [V.m-1]
Loss of lithium inventory, including electrolyte [%]
Negative electrolyte concentration
Negative electrolyte concentration [Molar]
Negative electrolyte concentration [mol.m-3]
Negative electrolyte potential [V]
Negative electrolyte transport efficiency
Positive electrolyte concentration
Positive electrolyte concentration [Molar]
Positive electrolyte concentration [mol.m-3]
Positive electrolyte potential [V]
Positive electrolyte transport efficiency
Separator electrolyte concentration
Separator electrolyte concentration [Molar]
Separator electrolyte concentration [mol.m-3]
Separator electrolyte potential [V]
Separator electrolyte transport efficiency
Sum of electrolyte reaction source terms [A.m-3]
Sum of negative electrode electrolyte reaction source terms [A.m-3]
Sum of positive electrode electrolyte reaction source terms [A.m-3]
Sum of x-averaged negative electrode electrolyte reaction source terms [A.m-3]
Sum of x-averaged positive electrode electrolyte reaction source terms [A.m-3]
Total lithium in electrolyte [mol]
Total lithium lost from electrolyte [mol]
X-averaged battery electrolyte ohmic losses [V]
X-averaged electrolyte concentration
X-averaged electrolyte concentration [Molar]
X-averaged electrolyte concentration [mol.m-3]
X-averaged electrolyte ohmic losses [V]
X-averaged electrolyte overpotential [V]
X-averaged electrolyte potential [V]
X-averaged negative electrolyte concentration
X-averaged negative electrolyte concentration [Molar]
X-averaged negative electrolyte concentration [mol.m-3]
X-averaged negative electrolyte potential [V]
X-averaged negative electrolyte transport efficiency
X-averaged positive electrolyte concentration
X-averaged positive electrolyte concentration [Molar]
X-averaged positive electrolyte concentration [mol.m-3]
X-averaged positive electrolyte potential [V]
X-averaged positive electrolyte transport efficiency
X-averaged separator electrolyte concentration
X-averaged separator electrolyte concentration [Molar]
X-averaged separator electrolyte concentration [mol.m-3]
X-averaged separator electrolyte potential [V]
X-averaged separator electrolyte transport efficiency
```

We have tried to make variables names fairly self explanatory.

As a first example, we choose to plot the voltage. We add this to a list and then pass this list to the `plot`

method of our simulation:

```
[4]:
```

```
output_variables = ["Voltage [V]"]
sim_dfn.plot(output_variables=output_variables)
```

```
[4]:
```

```
<pybamm.plotting.quick_plot.QuickPlot at 0x1077ee910>
```

Alternatively, we may be interested in plotting both the electrolyte concentration and the voltage. In which case, we would do:

```
[5]:
```

```
output_variables = ["Electrolyte concentration [mol.m-3]", "Voltage [V]"]
sim_dfn.plot(output_variables=output_variables)
```

```
[5]:
```

```
<pybamm.plotting.quick_plot.QuickPlot at 0x13a8fbe80>
```

You can also plot multiple variables on the same plot by nesting lists

```
[6]:
```

```
sim_dfn.plot(
[
["Electrode current density [A.m-2]", "Electrolyte current density [A.m-2]"],
"Voltage [V]",
]
)
```

```
[6]:
```

```
<pybamm.plotting.quick_plot.QuickPlot at 0x13aaadd60>
```

```
[7]:
```

```
sim_dfn.plot()
```

```
[7]:
```

```
<pybamm.plotting.quick_plot.QuickPlot at 0x13ab92e20>
```

For plotting the voltage components you can use the `plot_votage_components`

function

```
[8]:
```

```
pybamm.plot_voltage_components(sim_dfn.solution)
```

```
[8]:
```

```
(<Figure size 640x480 with 1 Axes>, <AxesSubplot: xlabel='Time [h]'>)
```

And with a few modifications (by creating subplots and by providing the axes on which the voltage components have to be plotted), it can also be used to compare the voltage components of different simulations

```
[9]:
```

```
# simulating and solving Single Particle Model
model_spm = pybamm.lithium_ion.SPM()
sim_spm = pybamm.Simulation(model_spm)
sim_spm.solve([0, 3700])
# comparing voltage components for Doyle-Fuller-Newman model and Single Particle Model
fig, axes = plt.subplots(1, 2, figsize=(15, 6), sharey=True)
pybamm.plot_voltage_components(sim_dfn.solution, ax=axes.flat[0])
pybamm.plot_voltage_components(sim_spm.solution, ax=axes.flat[1])
axes.flat[0].set_title("Doyle-Fuller-Newman Model")
axes.flat[1].set_title("Single Particle Model")
plt.show()
```

In this tutorial we have seen how to use the plotting functionality in PyBaMM.

In Tutorial 4 we show how to change parameter values.

## References#

The relevant papers for this notebook are:

```
[10]:
```

```
pybamm.print_citations()
```

```
[1] Weilong Ai, Ludwig Kraft, Johannes Sturm, Andreas Jossen, and Billy Wu. Electrochemical thermal-mechanical modelling of stress inhomogeneity in lithium-ion pouch cells. Journal of The Electrochemical Society, 167(1):013512, 2019. doi:10.1149/2.0122001JES.
[2] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, and Moritz Diehl. CasADi – A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019. doi:10.1007/s12532-018-0139-4.
[3] Rutooj Deshpande, Mark Verbrugge, Yang-Tse Cheng, John Wang, and Ping Liu. Battery cycle life prediction with coupled chemical degradation and fatigue mechanics. Journal of the Electrochemical Society, 159(10):A1730, 2012. doi:10.1149/2.049210jes.
[4] Marc Doyle, Thomas F. Fuller, and John Newman. Modeling of galvanostatic charge and discharge of the lithium/polymer/insertion cell. Journal of the Electrochemical society, 140(6):1526–1533, 1993. doi:10.1149/1.2221597.
[5] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.
[6] Scott G. Marquis, Valentin Sulzer, Robert Timms, Colin P. Please, and S. Jon Chapman. An asymptotic derivation of a single particle model with electrolyte. Journal of The Electrochemical Society, 166(15):A3693–A3706, 2019. doi:10.1149/2.0341915jes.
[7] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). Journal of Open Research Software, 9(1):14, 2021. doi:10.5334/jors.309.
```