GithubHelp home page GithubHelp logo

bedbad / justpyplot Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 31.04 MB

Plot in NumPy arrays directly, overlay NumPy plots straight over video real-time, plot in Jupyter without a single loop

License: MIT License

Python 97.04% Shell 2.96%
plot plotting plotting-in-python plot-in-numpy plotting-directly-numpy plotting-in-numpy matplotlib-figures matplotlib-python vectorized vectorized-computation

justpyplot's Introduction

# Plot in Numpy, Debug Visually Real-Time

This is concept of the real-time, vectorized plotting library which gets your plot as a numpy array controlling every basic part of it you may need - including opacity;

It's useful if you want to take control of your plot rendering/recording in your own hands for grab your plots directly for overlaying, GIFing visual debugging, tweaking, streaming, etc; It allows direct control and access img masks of 4 elemental properties of plot: figures, grid, axis and labels

It measured at 20-100x performance of matplotlib.

timer "full justpyplot + rendering": avg 382 µs ± 135 µs, max 962 µs

MOTIVATION

Python Plotting status quo: matplotlib and other major libs that copy it need 3-6 step hoopla to get as simple numpy arrays figures, grid, axis and labels of your plot.

The status quo basically requires you to screenshot in memory and buffer byter data back to pixel/img tensor. That makes you suffer multimillisecond performance hit every plot frame

Obviously it's very unpleasant to write such hoopla if you want to frab your plot frames.
Having plot frames you can do tweaking/publishing/rendering/GIFing etc.. yourself and, importantly for computer vision, it's too much a performance looser for real-time aspect of what you plot, such as testing and debugging, physical/manual manipulation of CV/camera/mechanical setup.

Also: it is a hermetic python plotlib rewrite - it doesn't suffer from other matplotlib vices.
Also: this code is an instance of plotting/rendering done in vectorized way which is important in ML/AI industry - the plot workflow can be directly embedded in visual neural networks

If there's enough demand here for real-time plotting, visual debugging for camera/computer vision applications and quick image graphs, I will a solid level of this library, with more competitive basic feature set to that of matplotlib.

INSTALATION

You can copy justplot file code respecting the license; For use in Jupyter notebooks its convienent to:

pip install justpyplot

BASIC USAGE

Basic Usage

You can explore the documentation for the justplot function currently, options probably support any flexing or adjusting the plot as you need such as colors, scatter, connected with line thickness, labels, etc

You just pass one or two arrays signifying dependency and pass it to the justplot. You can plot on exiting image frame at specified offset by plot1_at, plot2_at function or directly generate plot mask, you can completely control opacity of every element as well as every graphical or textual parameter of the plot.

import numpy as np 
import cv2
import time
from justpyplot import justpyplot as jplt

xs, ys = [], []
while(cv2.waitKey(1) != 27):
    xt = time.perf_counter() - t0
    yx = np.sin(xt)
    xs.append(xt)
    ys.append(yx)
    
    frame = np.full((500,470,3), (255,255,255), dtype=np.uint8)
    
    vals = np.array(ys)

    plotted_in_array = jplt.plot1(frame, vals,title="sin() from Clock")
    
    cv2.imshow('np array plot', plotted_in_array)

justpyplot's People

Contributors

bedbad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

justpyplot's Issues

LICENSE and USAGE

I would like to use the project, but without a license I cannot do so in the workplace.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.