{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Visualize a dataset\n", "\n", "The package includes basic tools to visualize BDF data as line plots. This notebook demonstrates the core functionality, including:\n", "\n", "- default plotting of a minimal dataset\n", "- custom plotting of defined quantities\n", "- adding a secondary axis to the plot\n", "- converting units in the plot\n", "- interactive exploration with bdf.explore\n" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "import bdf" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "# Read and normalize a source dataset for plotting\n", "df, meta = bdf.read(\"https://zenodo.org/records/17289383/files/SINTEF__NaCR32140-MP10-04__2025-08-25__GITT_0p05C_25degC__BioLogic.mpt\")\n", "df = df.to_pandas()\n", "df.head()" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "# The package plots Voltage / V versus Test Time / s by default, if no other information is provided\n", "bdf.plot(df)" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "# The user can also make custom plots from the dataframe\n", "bdf.plot(\n", " df,\n", " xdata=\"Test Time / s\",\n", " ydata=\"Net Capacity / Ah\"\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "# The yydata option can be added to introduce a secondary axis\n", "bdf.plot(\n", " df,\n", " xdata=\"Test Time / s\",\n", " ydata=\"Voltage / V\",\n", " yydata=\"Current / A\"\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "# Unit conversions can also be done directly in the plot function without additional steps\n", "bdf.plot(\n", " df,\n", " xdata=\"Test Time / s\", xunit=\"h\",\n", " ydata=\"Voltage / V\",\n", " yydata=\"Current / A\", yyunit=\"mA\"\n", ")" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "## Interactive exploration\n", "\n", "Use `bdf.explore` for interactive plots. Choose a backend:\n", "\n", "- `backend=\"plotly\"` (supported by default)\n", "- `backend=\"bokeh\"` (requires `pip install batterydf[hvplot]`)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "# Interactive exploration with Plotly\n", "bdf.explore(\n", " df,\n", " xdata=\"Test Time / s\", xunit=\"h\",\n", " ydata=\"Voltage / V\",\n", " yydata=\"Current / A\", yyunit=\"mA\",\n", " backend=\"plotly\",\n", " kind=\"line\",\n", ")\n" ] } ], "metadata": { "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.10" } }, "nbformat": 4, "nbformat_minor": 5 }