Plot live data that updates in real time using matplotlib backend
Project description
live_plotter
Plot live data that updates in real time using matplotlib backend
Installing
Install:
pip install live_plotter
Usage
In this library, we have two axes of variation. The first axis of variation is using either LivePlotter or FastLivePlotter. LivePlotter is more flexible and dynamic, but this results in slower updates. FastLivePlotter requires that the user specify the figure's shape from the beginning, but this allows it to update faster by modifying an existing plot rather than creating a new plot from scratch. Please refer to the associated example code for more details. The second axis of variation is using either LivePlotter or LivePlotterGrid. LivePlotter creates 1 plot, while LivePlotterGrid creates a grid of plots.
Lastly, you can add save_to_file_on_close=True to save the figure to a file when the live plotter is deleted (either out of scope or end of script). You can add save_to_file_on_exception=True to save the figure to a file when an exception occurs. Note this feature is experimental.
Options:
-
LivePlotter -
LivePlotterGrid -
FastLivePlotter -
FastLivePlotterGrid
Live Plotter
python live_plotter.py
Fast Live Plotter
python fast_live_plotter.py
Example Usage of LivePlotter
import numpy as np
from live_plotter import LivePlotter
live_plotter = LivePlotter(default_title="sin")
x_data = []
for i in range(25):
x_data.append(i)
live_plotter.plot(x_data=np.array(x_data), y_data=np.sin(x_data))
Example Usage of FastLivePlotter
import numpy as np
from live_plotter import FastLivePlotter
live_plotter = FastLivePlotter(title="sin")
x_data = []
for i in range(25):
x_data.append(i)
live_plotter.plot(x_data=np.array(x_data), y_data=np.sin(x_data))
Example Usage of LivePlotterGrid
import numpy as np
from live_plotter import LivePlotterGrid
live_plotter_grid = LivePlotterGrid(default_title="sin")
x_data = []
x_data2 = []
for i in range(25):
x_data.append(i)
x_data2.append(i)
live_plotter_grid.plot_grid(
x_data_list=[np.array(x_data), np.array(x_data2)],
y_data_list=[np.sin(x_data), np.cos(x_data2)],
n_rows=2,
title=["sin", "cos"],
)
Example Usage of FastLivePlotterGrid
import numpy as np
from live_plotter import FastLivePlotterGrid
live_plotter_grid = FastLivePlotterGrid(title="sin cos", n_rows=2, n_cols=1)
x_data = []
x_data2 = []
for i in range(25):
x_data.append(i)
x_data2.append(i)
live_plotter_grid.plot_grid(
x_data_list=[np.array(x_data), np.array(x_data2)],
y_data_list=[np.sin(x_data), np.cos(x_data2)],
)
Example Usage of FastLivePlotterGrid (more complex)
import numpy as np
from live_plotter import FastLivePlotterGrid
NUM_DATAS = 7
live_plotter_grid = FastLivePlotterGrid.from_desired_n_plots(
title="exp", desired_n_plots=NUM_DATAS
)
x_data_list = [[] for _ in range(NUM_DATAS)]
y_data_list = [[] for _ in range(NUM_DATAS)]
for i in range(25):
# Add new data
for j in range(NUM_DATAS):
x_data_list[j].append(i)
y_data_list[j].append(np.exp(-j / 10 * i))
live_plotter_grid.plot_grid(
x_data_list=[np.array(x_data) for x_data in x_data_list],
y_data_list=[np.array(y_data) for y_data in y_data_list],
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file live_plotter-0.0.3.tar.gz.
File metadata
- Download URL: live_plotter-0.0.3.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e6ea3e0f25f74753b33ce05680ba9397fae42ef17c69df42e05966d6a558a9e
|
|
| MD5 |
4da79bb26747afad5d9c8be6e03f2611
|
|
| BLAKE2b-256 |
bbabb859013700820f8315958a86174e361927cbcdb34450348c713653f5fa76
|
File details
Details for the file live_plotter-0.0.3-py3-none-any.whl.
File metadata
- Download URL: live_plotter-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ead76334c970f1877518f90fee0b60b3618faeb7489f48b55a71204da505b83f
|
|
| MD5 |
32a20b1a13f9dc7e9dfb5dd1e748c356
|
|
| BLAKE2b-256 |
ef4d298f4d8c61ecb376423a1f71d4b7042eaa950b6da37b064aa034dae5e723
|