Real time plotting. Yes, you can do it now.
Project description
rtplot
Author: Nabeel Sherazi, sherazi.n@husky.neu.edu
Have you ever noticed how if you want to plot a data stream in real time using matplotlib, it's uhhhhhh absolutely impossible? Like something about FuncAnimation and threading and basically all of this stuff -- IT'S SO FRICKING HARD TO JUST PLOT A DATA STREAM IN REAL TIME.
Well I Googled about this for like six hours and found literally not a single library that would just let me looking at a frickin stream of numbers in real time. So I said okay fine I'll just frickin write it myself and then put it out there so no one ever has to struggle with this again.
Presenting: rtplot -- it's real time plotting, but it's actually easy!!! For once!!!
Literally just import it. Start a plot. Push data to the plot whenever you want. Or don't. It literally doesn't matter. rtplot can do real-time XY plots and real time timeseries (single variable) data. It's so sweet. It can do multiple plots too. Like 20 timeseries at once. At 60 fps. Seriously.
Usage
Look at this.
from rtplot import TimeSeries
plot = TimeSeries(seconds_to_show=10)
plot.start()
while True:
new_data = read_sensor_data()
plot.update(new_data)
plot.quit()
BRUH!!!!!
from rtplot import XY
plot = XY(seconds_to_show=3) # Or not! Leave blank to show all data
plot.start()
while True:
xy1 = robot1.position()
xy2 = robot2.position()
plot.update([xy1, xy2])
plot.quit()
Supports context managers, custom linestyles, static background drawings, shortcuts, and more too!!! It's so fricking BATTERIES INCLUDED.
# Context manager
with rtplot.XY() as plot:
xy = datastream.read()
plot.update(x, y)
# Statics
plot1 = rtplot.TimeSeries(seconds_to_show=10, linestyle='r-')
plot1.add_static("vline", x=5)
# Shortcuts for common linestyles
import rtplot.shortcuts.shape as shape_shortcuts
plot1.add_static("rectangle", **shape_shortcuts.blue_dotted_stroke)
# By the way, this is safe since EVERY PLOT IS IN ITS OWN THREAD!!!
plot1.start()
plot2 = rtplot.XY(seconds_to_show=10, linestyle=["r-", "b:"]) # Let rtplot know in advance there should be two lines
plot2.start()
Basically this stuff goes off man.
Install
Either download this repo or just run pip install rtplot
Natively Python 3 unlike some of the solutions I found!!!! Only external dependencies numpy and matplotlib. One day I'll write some real docs for this but for now the source code is really small so if you don't get how to use something just look at the source code. I think I commented it pretty well. Also see the examples.
DEUCES
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 rtplot-2.1.2.tar.gz.
File metadata
- Download URL: rtplot-2.1.2.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
266888a9b5c6b6731c34cd907a040896c9dd57e4f29f8c901ab9fffd7893df7a
|
|
| MD5 |
f248cee5b9d3e09edbabf68c3e98ba22
|
|
| BLAKE2b-256 |
2e68554388a990d897f5eb8241ec9e29c053f5a9ac00ac5c5beb3b8fd7aa3d8c
|
File details
Details for the file rtplot-2.1.2-py3-none-any.whl.
File metadata
- Download URL: rtplot-2.1.2-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ce0f0a594679e5da6c1f4e20cc4604e5a05654e8f14c330738911d875e2bae4
|
|
| MD5 |
9016e0f0e4fc2622b9c81b96415c8926
|
|
| BLAKE2b-256 |
bc6f93d3be91db116f3ec567c203815519e0d863d5e913f5de0e6302df5c3ac8
|