jupyterplot
Create real-time plots in Jupyter notebooks.
What is it?
It generalises Andreas Madsen's excellent python-lrcurve library for machine learning to produce visualisations for arbitrary functions in real-time.
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 snippet:
from jupyterplot import ProgressPlot
import numpy as np
pp = ProgressPlot()
for i in range(1000):
pp.update(np.sin(i / 100))
pp.finalize()
Note: The pp.finalize() statement is necessary to make the plots persistent between notebook sessions.
Custom range
By default, the x and y ranges adapt to new data points. If the scale is known beforehand, it can be steadier to set it beforehand:
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()
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.
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()
Note: The data is fed to pp.update() as a list of lists, where each sublist corresponds to the curves that are generated in each subplot.
Multiple plots
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()
Custom x-values
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 or float and y follows the same format as in the previous examples.
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()
Decoupled y-limits
If each subplot should have different y-limits then the y-limits can be passed as a list containing the the limits for each subplot.
pp = ProgressPlot(plot_names=['plot 1', 'plot 2'], x_lim=[0, 1000], y_lim=[[0, 10],[0, 100]])
for i in range(1000):
pp.update([[(i/100)], [(i/100)**2]])
Input format
Single plot, single line
If the progress plot consists of a single plot with a single line one can pass the y-updates as int or float.
Multiple plots, multiple lines
If multiple plots or lines are used, the y-updates can either be lists or dicts:
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.
Release files for jupyterplot 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jupyterplot-0.0.3.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jupyterplot-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / jupyterplot-0.0.3.tar.gz
| Download URL | jupyterplot-0.0.3.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d531ca147992a37814ffcfad4144794c3ed3e8a00db6771725ff3a8d5177837
|
|
BLAKE2b-256 checksum How to use checksums |
b6e9a6dc9d0910e3f17a99ec8273607ed127e7742a8ca3382dc1685872bbb6d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / jupyterplot-0.0.3-py3-none-any.whl
| Download URL | jupyterplot-0.0.3-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e0c31502754728fecea4880331edd4f5acc2a7749b560f1e9e9902499783c40
|
|
BLAKE2b-256 checksum How to use checksums |
bc1ea0d35c9ac6dbf62f11c380ca2fcdc39a68d05b865f7757db3a38df8a9bb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|