Get your plot in you array, plot fast
Project description
Why not just get your plots in numpy?!
Why not just have a simple APIplot(values, grid_options, figure_options, ...) -> (figures, grid, axis,labels)
which renders plot in numpy/tensors and you can overlay, mask, transform, publish in any way you want whilst fully controlling every detail of your plot and figures?
Installation
pip install justpyplot
JustPyPlot: Fast NumPy-Native Plotting
So Why Yes?
- Fast: Vectorized plotting directly to NumPy arrays - no memory screenshots or buffer copies A high-performance plotting library that renders directly to NumPy arrays. Measured 20-100x faster than matplotlib:
timer "full justpyplot + rendering": avg 382 µs ± 135 µs, max 962 µs
- Simple: Get all plots parts as arrays with a single function call
figure, grid, axis, labels = jplt.plot(values,grid_opts,figure_opts,title,(600, 400))
and put them on, in or into everwhere you need in 1-2 subsequent lines
-
Flexible: Control every plot element (figures, grid, axis, labels) and every detail of plotting options independently, all design options are parsed from json-style figure and grid option dicts with full documentation available: https://justpyplot.readthedocs.io/en/latest/
-
No dependencies: Just vectorized python with numpy(+ other tensor lib you need), which makes standalone and compatible with any use case
-
Small Less then 20K total and 1000 total of core code which you can all understand
-
Real-time: Was initially scrapped for computer vision and robotics for real-time visualization and physical debugging tasks where standard plotting failed
-
ML/AI Pluggable: You can, for example stick it onto visual layers of neural network for it to learn your plotted characteristic without changing any dimensions.
BASIC USAGE
You can explore the documentation for the plot function which supports any flexing or adjusting of the plot as you need such as colors, scatter, connected with line thickness, labels, etc.
import numpy as np
import cv2
import time
from justpyplot import justpyplot as jplt
t0 = time.perf_counter()
xs, ys = [], []
while(cv2.waitKey(1) != 27): # Press ESC to exit
xt = time.perf_counter() - t0
yx = np.sin(xt)
xs.append(xt)
ys.append(yx)
# Create plot data array
plot_data = np.array([xs, ys])
# Generate plot arrays with customized options
figure, grid, labels, title_img = jplt.plot(
plot_data,
grid={'nticks': 5, 'color': (128, 128, 128, 255)},
figure={'scatter': True, 'line_color': (255, 0, 0, 255), 'line_width': 2},
title="sin() from Clock",
size=(600, 400)
)
# Blend all plot layers into single image
plotted_array = jplt.blend(figure, grid, labels, title_img)
cv2.imshow('np array plot', plotted_array)
Overlaying Multiple Plots
You take to take your plot which you can mask, stretch, transform and render wherever in frame array/canvas/memory you need and just overlay it simpler in one line?
Here 1-liner function implementing those basic steps stuck on running mug neural network. In 3 lines of code it shows how to mess and visually debug 3d position of computer vision/robotics object in physical world (try in examples/mug_objectron/demo.py):
jplt.plot1_at(image, ang_zs,
title='Angle from Z axis', offset=(50,50), size=(270, 300),
point_color=(255,0,0),line_color=(255,0,0), label_color=(255,0,0), grid_color=(126,126,126))
jplt.plot1_at(image, ang_ys,
title='Angle from Y axis', offset=(400,50), size=(270, 300),
point_color=(0,255,0), line_color=(0,255,0),label_color=(0,255,0), grid_color=(126,126,126),
scatter=False)
jplt.plot1_at(image,ang_xs,
title='Angle from X axis', offset=(750,50), size=(270, 300),
point_color=(0,0,255), line_color=(0,0,255),label_color=(0,0,255), grid_color=(126,126,126),
scatter=False)
Jupyter Notebook Usage
For jupyter support you can render images anyhow you like. One of the simplest is to use the blend2PIL function depening on Pillow package which will blend all the plot layers into a single PIL image buffer which you display in notebook
import numpy as np
from IPython.display import Image as ipyImage, display
from justpyplot import justpyplot as jplt
# Make some dependency data
x = np.linspace(0, 10, 50)
y = np.sin(x)
# Just plot in numpy using the plot() function
figure_img, grid_img, labels_img, title_img = jplt.plot(
np.array([x, y]),
grid={'nticks': 10, 'color': (128, 128, 128, 255), 'label_color': (255, 0, 0, 255),'precision': 1, 'label_font_size': 0.9},
figure={'scatter':False,'point_color': (255, 0, 0, 255), 'point_radius':3, 'line_color':(0,64,64, 255), 'line_width': 2, 'marker_style':'circle'},
title='Sine Wave',
size=(300, 400),
max_len=100
)
# blend arrays into PIL picture buffer (requires Pillow)
buffer = jplt.blend2PIL(grid_img, figure_img, labels_img, title_img, format='PNG')
# Display the image
display(ipyImage(buffer.getvalue()))
Documentation
Documentation is fully available at https://justpyplot.readthedocs.io/en/latest/
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
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 justpyplot-0.2.4.tar.gz.
File metadata
- Download URL: justpyplot-0.2.4.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43a79eb104544058a744d8dce40a4065f8578762822374029b82337d2ef2be1d
|
|
| MD5 |
063093e65a4f0af17bdeb86c6927161a
|
|
| BLAKE2b-256 |
dbe6a68067a5e008edba57ad9c8cae4f51a45bcb4f69780a525c13bed86feffd
|
Provenance
The following attestation bundles were made for justpyplot-0.2.4.tar.gz:
Publisher:
python-publish.yml on bedbad/justpyplot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
justpyplot-0.2.4.tar.gz -
Subject digest:
43a79eb104544058a744d8dce40a4065f8578762822374029b82337d2ef2be1d - Sigstore transparency entry: 175419207
- Sigstore integration time:
-
Permalink:
bedbad/justpyplot@5d8b33fbc6ed697273fba113016ec7df72772e1b -
Branch / Tag:
refs/tags/0.2.4 - Owner: https://github.com/bedbad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5d8b33fbc6ed697273fba113016ec7df72772e1b -
Trigger Event:
release
-
Statement type:
File details
Details for the file justpyplot-0.2.4-py2.py3-none-any.whl.
File metadata
- Download URL: justpyplot-0.2.4-py2.py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5fe3a2071b5e0059592ca3f7a2445244f4446af4be50491964e0f528a5ed8ec
|
|
| MD5 |
98a559543c7cccc0db00fbaad1e57797
|
|
| BLAKE2b-256 |
a8d6541b028cb8351abcb815d4548911a649565b9b845047032754e9df0448d4
|
Provenance
The following attestation bundles were made for justpyplot-0.2.4-py2.py3-none-any.whl:
Publisher:
python-publish.yml on bedbad/justpyplot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
justpyplot-0.2.4-py2.py3-none-any.whl -
Subject digest:
f5fe3a2071b5e0059592ca3f7a2445244f4446af4be50491964e0f528a5ed8ec - Sigstore transparency entry: 175419209
- Sigstore integration time:
-
Permalink:
bedbad/justpyplot@5d8b33fbc6ed697273fba113016ec7df72772e1b -
Branch / Tag:
refs/tags/0.2.4 - Owner: https://github.com/bedbad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5d8b33fbc6ed697273fba113016ec7df72772e1b -
Trigger Event:
release
-
Statement type: