Skip to content

Commit

Permalink
docs: update readme and user manual to reflect plotting integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjholland committed Jan 3, 2025
1 parent 1e17cef commit 553350f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PyProBE works with numerous cyclers. For guidance on how to export your data to
<details>
<summary><strong style="font-size: 1.2em;">2. Accelerate battery data exploration</strong></summary>

PyProBE has a built-in [plotting](https://imperialcollegelondon.github.io/PyProBE/api/pyprobe.plot.html) module for fast and flexible visualisation of battery data. It also includes a graphical user interface (GUI)
PyProBE has built-in plotting methods that integrate with [matplotlib](https://matplotlib.org/), [hvplot](https://hvplot.holoviz.org/) and [seaborn](https://seaborn.pydata.org/index.html) for fast and flexible visualization of battery data. It also includes a graphical user interface (GUI)
for exploring data interactively, with almost no code. Run the
[getting started](./docs/source/examples/getting-started.ipynb) example locally to try the GUI.

Expand Down
51 changes: 38 additions & 13 deletions docs/source/user_guide/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,53 @@
Plotting
========

PyProBE has a plotting module that can display any :class:`~pyprobe.rawdata.RawData`
or :class:`~pyprobe.result.Result` object. The plotting module is based on
`plotly <https://plot.ly/python/>`_.
PyProBE includes plotting methods that integrate directly with popular Python visualisation
tools. Using a backend powered by `Pandas <https://pandas.pydata.org/>`_ and `matplotlib <https://matplotlib.org/>`_, you can call the
:func:`~pyprobe.result.Result.plot` method on any :class:`~pyprobe.result.Result` object.

You first create a plot instance:
For more interactive plotting, you can use install the optional dependency `hvPlot <https://hvplot.holoviz.org/>`_:

.. code-block:: bash
pip install 'PyProBE-Data[hvplot]'
This enables the :func:`~pyprobe.result.Result.hvplot` method which creates interactive plots for
visual inspection.

The :func:`~pyprobe.result.Result.plot` and :func:`~pyprobe.result.Result.hvplot`
interfaces are very similar. For example, creation of a simple plot might look like:

.. code-block:: python
plot = pyprobe.Plot()
result = cell.procedure['Procedure Name'].experiment('Experiment Name').cycle(1)
# for matplotlib
result.plot(x='Time [s]', y='Voltage [V]')
# for hvplot
result.hvplot(x='Time [s]', y='Voltage [V]')
Then you can add data to and display the plot:
PyProBE also includes a wrapper for the `Seaborn <https://seaborn.pydata.org/index.html>`_
package. This allows you to pass any :class:`~pyprobe.result.Result` object to the `data`
argument of any seaborn method:

.. code-block:: python
result = cell.procedure['Procedure Name'].experiment('Experiment Name').cycle(4).charge(2)
plot.add_line(result, 'Time [s]', 'Voltage [V]')
plot.show()
from pyprobe.plot import seaborn as sns
sns.scatterplot(result, x='Time [s]', y='Voltage [V]')
Seaborn must be installed as an optional dependency:

.. code-block:: bash
pip install 'PyProBE-Data[seaborn]'
:func:`~pyprobe.plot.Plot.add_line` adds a line to the plot. The first argument is the
:class:`~pyprobe.rawdata.RawData` or :class:`~pyprobe.result.Result` object data to be
plotted, the second and third arguments are quantities to plot in x and y.
All of these methods are light wrappers, meaning you can refer to the original package
documentation for details on methods to customise your plots further. To get started with
plotting view the :doc:`example <../examples/plotting>`.

For other plot types see the :class:`~pyprobe.plot.Plot` class documentation.

.. footbibliography::

0 comments on commit 553350f

Please sign in to comment.