Skip to main content

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

Release files for rtplot 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rtplot 2.1.2
File Size Uploaded
rtplot-2.1.2.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rtplot 2.1.2
File Interpreter ABI Platform
rtplot-2.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / rtplot-2.1.2.tar.gz

Download URL rtplot-2.1.2.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
266888a9b5c6b6731c34cd907a040896c9dd57e4f29f8c901ab9fffd7893df7a
BLAKE2b-256 checksum
How to use checksums
2e68554388a990d897f5eb8241ec9e29c053f5a9ac00ac5c5beb3b8fd7aa3d8c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rtplot-2.1.2-py3-none-any.whl

Download URL rtplot-2.1.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ce0f0a594679e5da6c1f4e20cc4604e5a05654e8f14c330738911d875e2bae4
BLAKE2b-256 checksum
How to use checksums
bc6f93d3be91db116f3ec567c203815519e0d863d5e913f5de0e6302df5c3ac8
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page