Metadata-Version: 2.1
Name: jupyterplot
Version: 0.0.1
Summary: Create real-time plots in Jupyter Notebooks.
Home-page: https://github.com/lvwerra/jupyterplot
Author: Leandro von Werra
Author-email: leandro.vonwerra@gmail.com
License: Apache Software License 2.0
Keywords: real-time,plot,jupyter,notebooks
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: lrcurve
Requires-Dist: numpy
Requires-Dist: matplotlib

<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: notebooks/index.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

# jupyterplot

> Create real-time plots in Jupyter notebooks.


## What is it?

This is a library to generate real-time plots in Jupyter notebooks with a tqdm-like interface. It is largely based on the [python-lrcurve](https://github.com/AndreasMadsen/python-lrcurve) library by Andreas Madsen.

![single-plot](notebooks/images/plot_multiple_static.gif)

## Install

`pip install jupyterplot`

## How to use
### Single plot

Creating a simple real-time plot in a Jupyter notebook is as easy as easy as the following line:
<div class="codecell" markdown="1">
<div class="input_area" markdown="1">

```
from jupyterplot import ProgressPlot
import numpy as np

pp = ProgressPlot()
for i in range(1000):
    pp.update(np.sin(i/100))
pp.finalize()
```

</div>

</div>

![single-plot](notebooks/images/plot_single_dynamic.gif)

**Note:** The `pp.finalize()` statement is necessary to make the plots persistent between notebook sessions.

### Custom range
By default, the x and y range adapt to new data points. If the scale is known beforehand, it might steadier to set it beforehand:
<div class="codecell" markdown="1">
<div class="input_area" markdown="1">

```
pp = ProgressPlot(x_lim=[0,1000],y_lim=[-1.5,1.5])
for i in range(1000):
    pp.update(np.sin(i/100))
pp.finalize()
```

</div>

</div>

![single-plot](notebooks/images/plot_single_static.gif)

### Multiple lines
One can also plot several lines in parallel by specifying the line names in the constructor and passing all values in a list.
<div class="codecell" markdown="1">
<div class="input_area" markdown="1">

```
pp = ProgressPlot(line_names=['lin', 'log', 'cos', 'sin'], x_lim=[0, 1000], y_lim=[-1,4])
for i in range(1000):
    pp.update([[i/250, np.log10(i+1), np.cos(i/100), np.sin(i/100)]])
pp.finalize()
```

</div>

</div>

![single-plot](notebooks/images/plot_multiple_static.gif)

**Note:** The data is fed with two brackets `[[y1, y2, y3]]`. The first list corresponds the plots, wheras the second list to each line of each plot as we will also see in the next example.

### Multiple plots
<div class="codecell" markdown="1">
<div class="input_area" markdown="1">

```
pp = ProgressPlot(plot_names=['cos', 'sin'], line_names=['data', 'delayed-data'], x_lim=[0, 1000], y_lim=[-1,1])
for i in range(1000):
    pp.update([[np.cos(i/100), np.cos((i+20)/100)], [np.sin(i/100), np.sin((i+20)/100)]])
pp.finalize()
```

</div>

</div>

![single-plot](notebooks/images/plot_multiple_plots_static.gif)

### Custom x-values
Finally, if the x values should not be incremented by 1 at every update one can set the `x_iterator=False`. This requires passing two values to the `update(x, y)`, where `x` is an `int`/`float` and `y` follows the same format as in the previous examples.
<div class="codecell" markdown="1">
<div class="input_area" markdown="1">

```
pp = ProgressPlot(x_iterator=False, x_label='custom-x', x_lim=[0,10000], y_lim=[0, 10])
for i in range(1000):
    pp.update(10*i, i/100)
pp.finalize()
```

</div>

</div>

![single-plot](notebooks/images/plot_single_static_custom.gif)

### Input format
#### Single plot, single line
If a the progress plot consists of a single plot with a single line one can pass the y-updates as int/floats.
#### Multiple plots, multiple lines
If multiple plots or lines are used, the y-updates can either be lists or dicts:
```python
y_update_list = [[y_plot_1_line_1, y_plot_1_line_2],
                 [y_plot_2_line_1, y_plot_2_line_2]]

y_update_dict = {'plot_name_1': {'line_name_1': y_plot_1_line_1,
                                 'line_name_2': y_plot_1_line_2},
                 'plot_name_2': {'line_name_1': y_plot_2_line_1,
                                 'line_name_2': y_plot_2_line_2}}
``` 

## Limitations

* Only one `ProgressPlot()` object can be used at a time. 
* Each subplot must have the same number of lines.
* The same color cycle for each subplot is used.


