Visualize a dataset#
The package includes basic tools to visualize BDF data as line plots. This notebook demonstrates the core functionality, including:
default plotting of a minimal dataset
custom plotting of defined quantities
adding a secondary axis to the plot
converting units in the plot
interactive exploration with bdf.explore
import bdf
# Read and normalize a source dataset for plotting
df, meta = bdf.read("https://zenodo.org/records/17289383/files/SINTEF__NaCR32140-MP10-04__2025-08-25__GITT_0p05C_25degC__BioLogic.mpt")
df = df.to_pandas()
df.head()
| Test Time / s | Voltage / V | Current / A | Cycle Count / 1 | Step ID | Step Time / s | Net Capacity / Ah | Charging Energy / Wh | Discharging Energy / Wh | Net Energy / Wh | Power / W | Internal Resistance / ohm | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.000000 | 1.714230 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 1 | 10.000000 | 1.714152 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 2 | 20.000001 | 1.714152 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 3 | 30.000001 | 1.714230 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 4 | 40.000002 | 1.714191 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
# The package plots Voltage / V versus Test Time / s by default, if no other information is provided
bdf.plot(df)
<Figure size 640x480 with 1 Axes>
# The user can also make custom plots from the dataframe
bdf.plot(
df,
xdata="Test Time / s",
ydata="Net Capacity / Ah"
)
<Figure size 640x480 with 1 Axes>
# The yydata option can be added to introduce a secondary axis
bdf.plot(
df,
xdata="Test Time / s",
ydata="Voltage / V",
yydata="Current / A"
)
<Figure size 640x480 with 2 Axes>
# Unit conversions can also be done directly in the plot function without additional steps
bdf.plot(
df,
xdata="Test Time / s", xunit="h",
ydata="Voltage / V",
yydata="Current / A", yyunit="mA"
)
<Figure size 640x480 with 2 Axes>
Interactive exploration#
Use bdf.explore for interactive plots. Choose a backend:
backend="plotly"(supported by default)backend="bokeh"(requirespip install batterydf[hvplot])
# Interactive exploration with Plotly
bdf.explore(
df,
xdata="Test Time / s", xunit="h",
ydata="Voltage / V",
yydata="Current / A", yyunit="mA",
backend="plotly",
kind="line",
)