Skip to main content

Create real-time plots in Jupyter Notebooks.

Project description

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 library by Andreas Madsen.

single-plot

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:

from jupyterplot import ProgressPlot
import numpy as np

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

single-plot

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:

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()

single-plot

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()

single-plot

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

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()

single-plot

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.

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()

single-plot

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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterplot-0.0.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

jupyterplot-0.0.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file jupyterplot-0.0.1.tar.gz.

File metadata

  • Download URL: jupyterplot-0.0.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for jupyterplot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9930b7dfc51a3498a9812a9223e07f0d916ce314cbd71af1b619b79fddd93a4c
MD5 56278d4b58c6a0b13ec5d45491342dbb
BLAKE2b-256 2f5e5acc1999ac138e376a57195861ff328c6beb4037aec7e6f546b25ee02d70

See more details on using hashes here.

File details

Details for the file jupyterplot-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: jupyterplot-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for jupyterplot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f0a357032aef381627dc9a0174a6ae177b13edb2d8d98c99c04f5af5f7cd157
MD5 ee7fa3822cf1f52c4142fedba7415925
BLAKE2b-256 07502aebd256cf2714cabbf6d07d146e36e69d2703a9e1466791452a06ac2ba2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page